private static boolean tryToSetValueThroughField ( OpenEngSBModelEntry entry , Object instance ) throws IllegalAccessException { try { Field field = instance . getClass ( ) . getDeclaredField ( entry . getKey ( ) ) ; field . setAccessible ( true ) ; field . set ( instance , entry . getValue ( ) ) ; field . setAccessible ( false ) ; return true ; } catch ( NoSuchFieldException e ) { // if no field with this name exist, try to use the corresponding setter } catch ( SecurityException e ) { // if a security manager is installed which don't allow this change of a field value, try // to use the corresponding setter } return false ; }
Tries to set the value of an OpenEngSBModelEntry to its corresponding field of the model . Returns true if the field can be set returns false if not .