public boolean hasHintType(int index) { return index < getHints().size() && getHint(index) != null; }
private List<?> mapArrayToList(Object srcObj, Object srcCollectionValue, FieldMap fieldMap, Object destObj) { Class<?> destEntryType; if (fieldMap.getDestHintContainer() != null) { destEntryType = fieldMap.getDestHintContainer().getHint(); } else { destEntryType = srcCollectionValue.getClass().getComponentType(); } List<?> srcValueList; if (CollectionUtils.isPrimitiveArray(srcCollectionValue.getClass())) { srcValueList = CollectionUtils.convertPrimitiveArrayToList(srcCollectionValue); } else { srcValueList = Arrays.asList((Object[]) srcCollectionValue); } return addOrUpdateToList(srcObj, fieldMap, srcValueList, destObj, destEntryType); }
public boolean hasHintType(int index) { return index < getHints().size() && getHint(index) != null; }
private List<?> mapArrayToList(Object srcObj, Object srcCollectionValue, FieldMap fieldMap, Object destObj, MappingContext context) { Class<?> destEntryType; if (fieldMap.getDestHintContainer() != null) { destEntryType = fieldMap.getDestHintContainer().getHint(); } else { destEntryType = srcCollectionValue.getClass().getComponentType(); } List<?> srcValueList; if (CollectionUtils.isPrimitiveArray(srcCollectionValue.getClass())) { srcValueList = CollectionUtils.convertPrimitiveArrayToList(srcCollectionValue); } else { srcValueList = Arrays.asList((Object[]) srcCollectionValue); } return addOrUpdateToList(srcObj, fieldMap, srcValueList, destObj, destEntryType, context); }
public Class<?> getDestHintType(Class<?> runtimeSrcClass) { if (getDestHintContainer() != null) { if (getSrcHintContainer() != null) { return getDestHintContainer().getHint(runtimeSrcClass, getSrcHintContainer().getHints()); } else { return getDestHintContainer().getHint(); } } else { return runtimeSrcClass; } }
public Class<?> getDestFieldType(Class<?> runtimeDestClass) { Class<?> result = null; if (isDestFieldIndexed()) { result = destHintContainer != null ? destHintContainer.getHint() : null; } if (result == null) { result = getDestPropertyDescriptor(runtimeDestClass).getPropertyType(); } return result; }
public Class<?> getHint(Class<?> clazz, List<Class<?>> clazzHints) { List<Class<?>> hintTypes = getHints(); int hintsSize = hintTypes.size(); if (hintsSize == 1) { return getHint(); } // validate sizes if (clazzHints.size() != hintsSize) { MappingUtils.throwMappingException( "When using multiple source and destination hints there must be exactly the same number of hints on the source and the destination."); } int count = 0; String myClazName = MappingUtils.getRealClass(clazz).getName(); int size = clazzHints.size(); for (int i = 0; i < size; i++) { Class<?> element = clazzHints.get(i); if (element.getName().equals(myClazName)) { return hintTypes.get(count); } count++; } return clazz; }
private List<?> mapArrayToList(Object srcObj, Object srcCollectionValue, FieldMap fieldMap, Object destObj, MappingContext context) { Class<?> destEntryType; if (fieldMap.getDestHintContainer() != null) { destEntryType = fieldMap.getDestHintContainer().getHint(); } else { destEntryType = srcCollectionValue.getClass().getComponentType(); } List<?> srcValueList; if (CollectionUtils.isPrimitiveArray(srcCollectionValue.getClass())) { srcValueList = CollectionUtils.convertPrimitiveArrayToList(srcCollectionValue); } else { srcValueList = Arrays.asList((Object[]) srcCollectionValue); } return addOrUpdateToList(srcObj, fieldMap, srcValueList, destObj, destEntryType, context); }
public Class<?> getHint(Class<?> clazz, List<Class<?>> clazzHints) { List<Class<?>> hints = getHints(); int hintsSize = hints.size(); if (hintsSize == 1) { return getHint(); } // validate sizes if (clazzHints.size() != hintsSize) { MappingUtils .throwMappingException("When using multiple source and destination hints there must be exactly the same number of hints on the source and the destination."); } int count = 0; String myClazName = MappingUtils.getRealClass(clazz).getName(); int size = clazzHints.size(); for (int i = 0; i < size; i++) { Class<?> element = clazzHints.get(i); if (element.getName().equals(myClazName)) { return hints.get(count); } count++; } return clazz; }
public static Class<?> determineCustomConverter(FieldMap fieldMap, Cache converterByDestTypeCache, CustomConverterContainer customConverterContainer, Class<?> srcClass, Class<?> destClass) { if (customConverterContainer == null) { return null; } // This method is messy. Just trying to isolate the junk into this one method instead of spread across the mapping // processor until a better solution can be put into place // For indexed mapping, need to use the actual class at index to determine the custom converter. if (fieldMap != null && fieldMap.isDestFieldIndexed()) { if (destClass.isArray()) { destClass = destClass.getComponentType(); } else if (destClass.isAssignableFrom(Collection.class) && fieldMap.getDestHintContainer() != null && !fieldMap.getDestHintContainer().hasMoreThanOneHint()) { // use hint when trying to find a custom converter destClass = fieldMap.getDestHintContainer().getHint(); } } return findCustomConverter(converterByDestTypeCache, customConverterContainer, srcClass, destClass); }
public Class<?> getDestHintType(Class<?> runtimeSrcClass) { if (getDestHintContainer() != null) { if (getSrcHintContainer() != null) { return getDestHintContainer().getHint(runtimeSrcClass, getSrcHintContainer().getHints()); } else { return getDestHintContainer().getHint(); } } else { return runtimeSrcClass; } }
.getDestHintContainer().hasMoreThanOneHint()) { destType = fieldMap.getDestHintContainer().getHint();
public Class<?> getHint(Class<?> clazz, List<Class<?>> clazzHints) { List<Class<?>> hintTypes = getHints(); int hintsSize = hintTypes.size(); if (hintsSize == 1) { return getHint(); } // validate sizes if (clazzHints.size() != hintsSize) { MappingUtils .throwMappingException("When using multiple source and destination hints there must be exactly the same number of hints on the source and the destination."); } int count = 0; String myClazName = MappingUtils.getRealClass(clazz).getName(); int size = clazzHints.size(); for (int i = 0; i < size; i++) { Class<?> element = clazzHints.get(i); if (element.getName().equals(myClazName)) { return hintTypes.get(count); } count++; } return clazz; }
.hasMoreThanOneHint()) { destType = fieldMap.getDestHintContainer().getHint();
public Class<?> getDestHintType(Class<?> runtimeSrcClass) { if (getDestHintContainer() != null) { if (getSrcHintContainer() != null) { return getDestHintContainer().getHint(runtimeSrcClass, getSrcHintContainer().getHints()); } else { return getDestHintContainer().getHint(); } } else { return runtimeSrcClass; } }
public Class<?> getDestFieldType(Class<?> runtimeDestClass) { Class<?> result = getDestPropertyDescriptor(runtimeDestClass).getPropertyType(); if (isDestFieldIndexed()) { HintContainer hintContainer = destField.getHintContainer(); if (hintContainer != null) { result = hintContainer.getHint(); } else if ((result.isArray() || (Collection.class.isAssignableFrom(result)) && MappingUtils.getSupportedCollectionEntryType(getDestPropertyDescriptor(runtimeDestClass)) != null)) { result = MappingUtils.getSupportedCollectionEntryType(getDestPropertyDescriptor(runtimeDestClass)); } else { result = Object.class; } } return result; }
public Class<?> getDestFieldType(Class<?> runtimeDestClass) { Class<?> result = getDestPropertyDescriptor(runtimeDestClass).getPropertyType(); if (isDestFieldIndexed()) { HintContainer hintContainer = destField.getHintContainer(); if (hintContainer != null) { result = hintContainer.getHint(); } else if ((result.isArray() || (Collection.class.isAssignableFrom(result)) && MappingUtils .getSupportedCollectionEntryType(getDestPropertyDescriptor(runtimeDestClass)) != null)) { result = MappingUtils.getSupportedCollectionEntryType(getDestPropertyDescriptor(runtimeDestClass)); } else { result = Object.class; } } return result; }