public static void initialize ( Object backend , BackendInstanceSpec backendInstanceSpec ) { assert backend != null : "backend cannot be null" ; assert backendInstanceSpec != null : "backendInstanceSpec cannot be null" ; for ( Method method : backend . getClass ( ) . getMethods ( ) ) { if ( method . isAnnotationPresent ( BackendProperty . class ) ) { try { BackendProperty annotation = method . getAnnotation ( BackendProperty . class ) ; String propertyName = propertyName ( annotation , method ) ; Object propertyValue = backendInstanceSpec . getProperty ( propertyName ) ; if ( propertyValue != null ) { method . invoke ( backend , new Object [ ] { propertyValue } ) ; } } catch ( IllegalAccessException | InvalidPropertyNameException | InvocationTargetException ex ) { throw new AssertionError ( ex ) ; } } } }
Sets the fields corresponding to the properties in the configuration .