public FieldPropertyDescriptor(Class<?> clazz, String fieldName, boolean isIndexed, String index, HintContainer deepIndexHintContainer) { super(clazz, fieldName, isIndexed, index, deepIndexHintContainer); String[] tokens = fieldName.split(DozerConstants.DEEP_FIELD_DELIMITER_REGEXP); descriptorChain = new DozerPropertyDescriptor[tokens.length]; Class<?> currentType = clazz; for (int i = 0, tokensLength = tokens.length; i < tokensLength; i++) { String token = tokens[i]; descriptorChain[i] = new ChainedPropertyDescriptor(currentType, token, isIndexed, index); if (i < tokensLength) { Field field = ReflectionUtils.getFieldFromBean(currentType, tokens[i]); currentType = field.getType(); } } }
public void setPropertyValue(Object bean, Object value, FieldMap fieldMap) { if (value == null && getPropertyType().isPrimitive()) { return; // do nothing } // Check if dest value is already set and is equal to src value. If // true, no need to rewrite the dest value if (getPropertyValue(bean) == value) { return; } try { if (indexed) { Object existingValue = field.get(bean); if (!MappingUtils.isSimpleCollectionIndex(index)) { MappingUtils .throwMappingException("Destinaiton field path should not contain filter expressions"); } Object collection = MappingUtils.prepareIndexedCollection(getPropertyType(), existingValue, value, MappingUtils.getCollectionIndex(index)); field.set(bean, collection); } else { field.set(bean, value); } } catch (IllegalAccessException e) { MappingUtils.throwMappingException(e); } }
public void setPropertyValue(Object bean, Object value, FieldMap fieldMap) { if (value == null && getPropertyType().isPrimitive()) { return; // do nothing } // Check if dest value is already set and is equal to src value. If // true, no need to rewrite the dest value if (getPropertyValue(bean) == value) { return; } try { if (indexed) { Object existingValue = field.get(bean); if (!MappingUtils.isSimpleCollectionIndex(index)) { MappingUtils.throwMappingException("Destinaiton field path should not contain filter expressions"); } Object collection = MappingUtils.prepareIndexedCollection(getPropertyType(), existingValue, value, MappingUtils.getCollectionIndex(index)); field.set(bean, collection); } else { field.set(bean, value); } } catch (IllegalAccessException e) { MappingUtils.throwMappingException(e); } }
public void setPropertyValue(Object bean, Object value, FieldMap fieldMap) { if (value == null && getPropertyType().isPrimitive()) { return; // do nothing } // Check if dest value is already set and is equal to src value. If true, no need to rewrite the dest value if (getPropertyValue(bean) == value) { return; } try { if (indexed) { Object existingValue = field.get(bean); Object collection = MappingUtils.prepareIndexedCollection(getPropertyType(), existingValue, value, index); field.set(bean, collection); } else { field.set(bean, value); } } catch (IllegalAccessException e) { MappingUtils.throwMappingException(e); } }
public FieldPropertyDescriptor(Class<?> clazz, String fieldName, boolean isIndexed, int index, HintContainer srcDeepIndexHintContainer, HintContainer destDeepIndexHintContainer) { super(clazz, fieldName, isIndexed, index, srcDeepIndexHintContainer, destDeepIndexHintContainer); String[] tokens = fieldName.split(DozerConstants.DEEP_FIELD_DELIMITER_REGEXP); descriptorChain = new DozerPropertyDescriptor[tokens.length]; Class<?> currentType = clazz; for (int i = 0, tokensLength = tokens.length; i < tokensLength; i++) { String token = tokens[i]; descriptorChain[i] = new ChainedPropertyDescriptor(currentType, token, isIndexed, index); if (i < tokensLength) { Field field = ReflectionUtils.getFieldFromBean(currentType, tokens[i]); currentType = field.getType(); } } }
public FieldPropertyDescriptor(Class<?> clazz, String fieldName, boolean isIndexed, String index, HintContainer deepIndexHintContainer) { super(clazz, fieldName, isIndexed, index, deepIndexHintContainer); String[] tokens = fieldName.split(DozerConstants.DEEP_FIELD_DELIMITER_REGEXP); descriptorChain = new DozerPropertyDescriptor[tokens.length]; Class<?> currentType = clazz; for (int i = 0, tokensLength = tokens.length; i < tokensLength; i++) { String token = tokens[i]; descriptorChain[i] = new ChainedPropertyDescriptor(currentType, token, isIndexed, index); if (i < tokensLength) { Field field = ReflectionUtils.getFieldFromBean(currentType, tokens[i]); currentType = field.getType(); } } }