public static <T> T invokeGetterMethod( String fieldName, Object target ) { Method method = findGetterMethod( fieldName, target ); if ( method != null ) { return invokeMethod( target, method ); } return null; }
public static <T> T invokeSetterMethod( String fieldName, Object target, Object... args ) { Method method = findSetterMethod( fieldName, target ); if ( method != null ) { return invokeMethod( target, method, args ); } return null; }
private <T extends IdentifiableObject> void clearEmbeddedObjects( T object, Collection<Property> properties ) { for ( Property property : properties ) { if ( property.isCollection() ) { ((Collection<?>) ReflectionUtils.invokeMethod( object, property.getGetterMethod() )).clear(); } else { ReflectionUtils.invokeMethod( object, property.getSetterMethod(), (Object) null ); } } }
@SuppressWarnings( { "unchecked", "rawtypes" } ) private Object collect( Object object, Property property ) { object = HibernateUtils.unwrap( object ); if ( Collection.class.isInstance( object ) ) { Collection<?> collection = (Collection<?>) object; List<Object> items = new ArrayList<>(); for ( Object item : collection ) { Object collect = collect( item, property ); if ( Collection.class.isInstance( collect ) ) { items.addAll( ((Collection) collect) ); } else { items.add( collect ); } } return items; } return ReflectionUtils.invokeMethod( object, property.getGetterMethod() ); } }
public int compare( Object lside, Object rside ) Object o1 = ReflectionUtils.invokeMethod( lside, property.getGetterMethod() ); Object o2 = ReflectionUtils.invokeMethod( rside, property.getGetterMethod() );
private <T extends IdentifiableObject> void handleEmbeddedObjects( T object, ObjectBundle bundle, Collection<Property> properties ) { for ( Property property : properties ) { if ( property.isCollection() ) { Collection<?> objects = ReflectionUtils.invokeMethod( object, property.getGetterMethod() ); objects.forEach( o -> { handleProperty( o, bundle, property ); } ); } else { Object o = ReflectionUtils.invokeMethod( object, property.getGetterMethod() ); handleProperty( o, bundle, property ); } } }
private Map<String, Map<Object, String>> handleUniqueProperties( Schema schema, List<IdentifiableObject> objects ) { List<Property> uniqueProperties = schema.getProperties().stream() .filter( p -> p.isPersisted() && p.isOwner() && p.isUnique() && p.isSimple() ) .collect( Collectors.toList() ); Map<String, Map<Object, String>> map = new HashMap<>(); for ( IdentifiableObject object : objects ) { uniqueProperties.forEach( property -> { if ( !map.containsKey( property.getName() ) ) map.put( property.getName(), new HashMap<>() ); Object value = ReflectionUtils.invokeMethod( object, property.getGetterMethod() ); if ( value != null ) map.get( property.getName() ).put( value, object.getUid() ); } ); } return map; }
@Override public <T extends IdentifiableObject> void preUpdate( T object, T persistedObject, ObjectBundle bundle ) { Schema schema = schemaService.getDynamicSchema( object.getClass() ); for ( Property property : schema.getPropertyMap().values() ) { if ( PeriodType.class.isAssignableFrom( property.getKlass() ) ) { PeriodType periodType = ReflectionUtils.invokeMethod( object, property.getGetterMethod() ); if ( periodType != null ) { periodType = bundle.getPreheat().getPeriodTypeMap().get( periodType.getName() ); ReflectionUtils.invokeMethod( object, property.getSetterMethod(), periodType ); } } } } }
objects.forEach( o -> list.addAll( ReflectionUtils.invokeMethod( o, property.getGetterMethod() ) ) ); targets.put( property.getItemKlass(), list ); objects.forEach( o -> list.add( ReflectionUtils.invokeMethod( o, property.getGetterMethod() ) ) ); targets.put( property.getKlass(), list );
@Override public <T extends IdentifiableObject> void preCreate( T object, ObjectBundle bundle ) { Schema schema = schemaService.getDynamicSchema( object.getClass() ); for ( Property property : schema.getPropertyMap().values() ) { if ( PeriodType.class.isAssignableFrom( property.getKlass() ) ) { PeriodType periodType = ReflectionUtils.invokeMethod( object, property.getGetterMethod() ); if ( periodType != null ) { periodType = bundle.getPreheat().getPeriodTypeMap().get( periodType.getName() ); periodType = periodService.reloadPeriodType( periodType ); ReflectionUtils.invokeMethod( object, property.getSetterMethod(), periodType ); } } } }
Object value = ReflectionUtils.invokeMethod( object, property.getGetterMethod() );
private void handleProperty( Object o, ObjectBundle bundle, Property property ) { if ( property.isIdentifiableObject() ) { ((BaseIdentifiableObject) o).setAutoFields(); } Schema embeddedSchema = schemaService.getDynamicSchema( o.getClass() ); for ( Property embeddedProperty : embeddedSchema.getPropertyMap().values() ) { if ( PeriodType.class.isAssignableFrom( embeddedProperty.getKlass() ) ) { PeriodType periodType = ReflectionUtils.invokeMethod( o, embeddedProperty.getGetterMethod() ); if ( periodType != null ) { periodType = bundle.getPreheat().getPeriodTypeMap().get( periodType.getName() ); ReflectionUtils.invokeMethod( o, embeddedProperty.getSetterMethod(), periodType ); } } } preheatService.connectReferences( o, bundle.getPreheat(), bundle.getPreheatIdentifier() ); } }
@SuppressWarnings( "unchecked" ) private List<Mutation> calculateMutation( String path, Property property, Object source, Object target ) Object sourceValue = ReflectionUtils.invokeMethod( source, property.getGetterMethod() ); Object targetValue = ReflectionUtils.invokeMethod( target, property.getGetterMethod() ); List<Mutation> mutations = new ArrayList<>();
IdentifiableObject reference = ReflectionUtils.invokeMethod( object, p.getGetterMethod() ); Collection<IdentifiableObject> references = ReflectionUtils.invokeMethod( object, p.getGetterMethod() );
IdentifiableObject refObject = ReflectionUtils.invokeMethod( object, property.getGetterMethod() ); IdentifiableObject ref = getPersistedObject( preheat, identifier, refObject ); ReflectionUtils.invokeMethod( object, property.getSetterMethod(), (Object) null ); ReflectionUtils.invokeMethod( object, property.getSetterMethod(), ref ); Collection<IdentifiableObject> refObjects = ReflectionUtils.invokeMethod( object, property.getGetterMethod() ); ReflectionUtils.invokeMethod( object, property.getSetterMethod(), objects );
Collection<T> sourceObject = ReflectionUtils.invokeMethod( source, property.getGetterMethod() ); Collection<T> targetObject = ReflectionUtils.invokeMethod( target, property.getGetterMethod() ); ReflectionUtils.invokeMethod( target, property.getSetterMethod(), targetObject ); Object sourceObject = ReflectionUtils.invokeMethod( source, property.getGetterMethod() ); ReflectionUtils.invokeMethod( target, property.getSetterMethod(), sourceObject );
Object value = ReflectionUtils.invokeMethod( object, property.getGetterMethod() );
IdentifiableObject refObject = ReflectionUtils.invokeMethod( object, p.getGetterMethod() ); IdentifiableObject ref = preheat.get( identifier, refObject ); Collection<IdentifiableObject> refObjects = ReflectionUtils.invokeMethod( object, p.getGetterMethod() ); ReflectionUtils.invokeMethod( object, p.getSetterMethod(), objects );
currentTarget = ReflectionUtils.invokeMethod( currentTarget, currentProperty.getGetterMethod() );
Object returnValue = ReflectionUtils.invokeMethod( object, property.getGetterMethod() );