private Object convertEDBObjectToUncheckedModel ( Class < ? > model , EDBObject object ) { if ( ! checkEDBObjectModelType ( object , model ) ) { return null ; } filterEngineeringObjectInformation ( object , model ) ; List < OpenEngSBModelEntry > entries = new ArrayList <> ( ) ; for ( PropertyDescriptor propertyDescriptor : getPropertyDescriptorsForClass ( model ) ) { if ( propertyDescriptor . getWriteMethod ( ) == null || propertyDescriptor . getName ( ) . equals ( ModelUtils . MODEL_TAIL_FIELD_NAME ) ) { continue ; } Object value = getValueForProperty ( propertyDescriptor , object ) ; Class < ? > propertyClass = propertyDescriptor . getPropertyType ( ) ; if ( propertyClass . isPrimitive ( ) ) { entries . add ( new OpenEngSBModelEntry ( propertyDescriptor . getName ( ) , value , ClassUtils . primitiveToWrapper ( propertyClass ) ) ) ; } else { entries . add ( new OpenEngSBModelEntry ( propertyDescriptor . getName ( ) , value , propertyClass ) ) ; } } for ( Map . Entry < String , EDBObjectEntry > objectEntry : object . entrySet ( ) ) { EDBObjectEntry entry = objectEntry . getValue ( ) ; Class < ? > entryType ; try { entryType = model . getClassLoader ( ) . loadClass ( entry . getType ( ) ) ; entries . add ( new OpenEngSBModelEntry ( entry . getKey ( ) , entry . getValue ( ) , entryType ) ) ; } catch ( ClassNotFoundException e ) { LOGGER . error ( "Unable to load class {} of the model tail" , entry . getType ( ) ) ; } } return ModelUtils . createModel ( model , entries ) ; }
Converts an EDBObject to a model by analyzing the object and trying to call the corresponding setters of the model .