/** * Copies the unmapped properties of the given {@link MappedProperties} from the source object to the target instance. * * @param properties must not be {@literal null}. * @param source must not be {@literal null}. * @param target must not be {@literal null}. */ private static void copyRemainingProperties(MappedProperties properties, Object source, Object target) { PropertyAccessor sourceFieldAccessor = PropertyAccessorFactory.forDirectFieldAccess(source); PropertyAccessor sourcePropertyAccessor = PropertyAccessorFactory.forBeanPropertyAccess(source); PropertyAccessor targetFieldAccessor = PropertyAccessorFactory.forDirectFieldAccess(target); PropertyAccessor targetPropertyAccessor = PropertyAccessorFactory.forBeanPropertyAccess(target); for (String property : properties.getSpringDataUnmappedProperties()) { // If there's a field we can just copy it. if (targetFieldAccessor.isWritableProperty(property)) { targetFieldAccessor.setPropertyValue(property, sourceFieldAccessor.getPropertyValue(property)); continue; } // Otherwise only copy if there's both a getter and setter. if (targetPropertyAccessor.isWritableProperty(property) && sourcePropertyAccessor.isReadableProperty(property)) { targetPropertyAccessor.setPropertyValue(property, sourcePropertyAccessor.getPropertyValue(property)); } } }
/** * {@inheritDoc} */ @Override public boolean isWriteOnly(Object instance, String propertyName) { PropertyAccessor accessor = PropertyProxyUtils.getPropertyAccessor(this.conversionService, this.useDirectFieldAccess, instance); return isReadIgnored(instance, propertyName) || (!accessor.isReadableProperty(propertyName) && accessor.isWritableProperty(propertyName)); }
if (paBean.isWritableProperty(key)) { paBean.setPropertyValue(key, value); else if (paDirect.isWritableProperty(key)) { paDirect.setPropertyValue(key, value);
private boolean isWriteIgnored(Object instance, String propertyName) { PropertyAccessor accessor = PropertyProxyUtils.getPropertyAccessor(this.conversionService, this.useDirectFieldAccess, instance); if (!accessor.isWritableProperty(propertyName)) { return true; } if (this.useDirectFieldAccess) { AmfIgnoreField ignoreField = accessor.getPropertyTypeDescriptor(propertyName).getAnnotation(AmfIgnoreField.class); return ignoreField != null && ignoreField.onDeserialization(); } else { PropertyDescriptor pd = ((BeanWrapper)accessor).getPropertyDescriptor(propertyName); return pd.getWriteMethod().getAnnotation(AmfIgnore.class) != null; } }
if (paBean.isWritableProperty(key)) { paBean.setPropertyValue(key, value); else if (paDirect.isWritableProperty(key)) { paDirect.setPropertyValue(key, value);
/** * Copies the unmapped properties of the given {@link MappedProperties} from the source object to the target instance. * * @param properties must not be {@literal null}. * @param source must not be {@literal null}. * @param target must not be {@literal null}. */ private static void copyRemainingProperties(MappedProperties properties, Object source, Object target) { PropertyAccessor sourceFieldAccessor = PropertyAccessorFactory.forDirectFieldAccess(source); PropertyAccessor sourcePropertyAccessor = PropertyAccessorFactory.forBeanPropertyAccess(source); PropertyAccessor targetFieldAccessor = PropertyAccessorFactory.forDirectFieldAccess(target); PropertyAccessor targetPropertyAccessor = PropertyAccessorFactory.forBeanPropertyAccess(target); for (String property : properties.getSpringDataUnmappedProperties()) { // If there's a field we can just copy it. if (targetFieldAccessor.isWritableProperty(property)) { targetFieldAccessor.setPropertyValue(property, sourceFieldAccessor.getPropertyValue(property)); continue; } // Otherwise only copy if there's both a getter and setter. if (targetPropertyAccessor.isWritableProperty(property) && sourcePropertyAccessor.isReadableProperty(property)) { targetPropertyAccessor.setPropertyValue(property, sourcePropertyAccessor.getPropertyValue(property)); } } }