public Set<String> getReadableFieldNames(Class<?> clazz) { Set<String> srcFieldNames = new HashSet<String>(); PropertyDescriptor[] srcProperties = ReflectionUtils.getPropertyDescriptors(clazz); for (PropertyDescriptor srcPropertyDescriptor : srcProperties) { String fieldName = srcPropertyDescriptor.getName(); if (srcPropertyDescriptor.getReadMethod() == null) { continue; } srcFieldNames.add(fieldName); } return srcFieldNames; }
public Set<String> getWritableFieldNames(Class<?> clazz) { Set<String> destFieldNames = new HashSet<String>(); PropertyDescriptor[] destProperties = ReflectionUtils.getPropertyDescriptors(clazz); for (PropertyDescriptor destPropertyDescriptor : destProperties) { String fieldName = destPropertyDescriptor.getName(); // If destination field does not have a write method, then skip if (destPropertyDescriptor.getWriteMethod() == null && ReflectionUtils.getNonVoidSetter(clazz, fieldName) == null) { continue; } destFieldNames.add(fieldName); } return destFieldNames; } }
public boolean apply(ClassMap classMap, Configuration configuration) { Class<?> srcType = classMap.getSrcClassToMap(); PropertyDescriptor[] srcProperties = ReflectionUtils.getPropertyDescriptors(srcType); for (PropertyDescriptor property : srcProperties) { Method readMethod = property.getReadMethod(); PropertyDescriptor[] destProperties = ReflectionUtils.getPropertyDescriptors(destType); for (PropertyDescriptor property : destProperties) { Method readMethod = property.getReadMethod();
public boolean apply(ClassMap classMap, Configuration configuration) { Class<?> srcType = classMap.getSrcClassToMap(); PropertyDescriptor[] srcProperties = ReflectionUtils.getPropertyDescriptors(srcType); for (PropertyDescriptor property : srcProperties) { Method readMethod = property.getReadMethod(); if (readMethod != null) { Mapping mapping = readMethod.getAnnotation(Mapping.class); String propertyName = property.getName(); if (mapping != null) { String pairName = mapping.value().trim(); GeneratorUtils.addGenericMapping(classMap, configuration, propertyName, pairName.isEmpty() ? propertyName : pairName); } } } Class<?> destType = classMap.getDestClassToMap(); PropertyDescriptor[] destProperties = ReflectionUtils.getPropertyDescriptors(destType); for (PropertyDescriptor property : destProperties) { Method readMethod = property.getReadMethod(); if (readMethod != null) { Mapping mapping = readMethod.getAnnotation(Mapping.class); String propertyName = property.getName(); if (mapping != null) { String pairName = mapping.value().trim(); GeneratorUtils.addGenericMapping(classMap, configuration, pairName.isEmpty() ? propertyName : pairName, propertyName); } } } return false; } }
result = hierarchy[hierarchy.length - 1].getPropDescriptor(); } else { PropertyDescriptor[] descriptors = getPropertyDescriptors(objectClass);
result = hierarchy[hierarchy.length - 1].getPropDescriptor(); } else { PropertyDescriptor[] descriptors = getPropertyDescriptors(objectClass);
result = hierarchy[hierarchy.length - 1].getPropDescriptor(); } else { PropertyDescriptor[] descriptors = getPropertyDescriptors(objectClass);
public boolean apply(ClassMap classMap, Configuration configuration) { Class<?> srcClass = classMap.getSrcClassToMap(); Class<?> destClass = classMap.getDestClassToMap(); PropertyDescriptor[] destProperties = ReflectionUtils.getPropertyDescriptors(destClass); for (PropertyDescriptor destPropertyDescriptor : destProperties) { String fieldName = destPropertyDescriptor.getName(); if (shouldIgnoreField(fieldName, srcClass, destClass)) { continue; } // If field has already been accounted for, then skip if (classMap.getFieldMapUsingDest(fieldName) != null || classMap .getFieldMapUsingSrc(fieldName) != null) { continue; } // If destination field does not have a write method, then skip if (destPropertyDescriptor.getWriteMethod() == null) { continue; } PropertyDescriptor srcProperty = ReflectionUtils.findPropertyDescriptor(srcClass, fieldName, null); // If the sourceProperty is null we know that there is not a // corresponding property to map to. // If source property does not have a read method, then skip if (srcProperty == null || srcProperty.getReadMethod() == null) { continue; } addGenericMapping(classMap, configuration, fieldName, fieldName); } return false; }
properties = ReflectionUtils.getPropertyDescriptors(destClass); } else { properties = ReflectionUtils.getPropertyDescriptors(srcClass); destinationIsMap = true;
properties = ReflectionUtils.getPropertyDescriptors(destClass); } else { properties = ReflectionUtils.getPropertyDescriptors(srcClass); destinationIsMap = true;