public boolean isPrimitive() { return type.isPrimitive(); }
public String generateEqualityTestCode(FieldMap fieldMap, VariableRef source, VariableRef destination, SourceCodeContext code) { if (source.type().isPrimitive() || source.type().isPrimitiveWrapper()) { return source + " == " + destination; } else { return source + ".equals(" + destination + ")"; } }
public String generateEqualityTestCode(FieldMap fieldMap, VariableRef source, VariableRef destination, SourceCodeContext code) { if (source.type().isPrimitive() || source.type().isPrimitiveWrapper()) { return source + " == " + destination; } else { return source + ".equals(" + destination + ")"; } }
private Type<?> primitiveSafeListType(Type<?> type) { if (type.isPrimitive()) { return type.getWrapperType(); } else { return type; } }
public boolean appliesTo(FieldMap fieldMap) { return String.class.equals(fieldMap.getSource().getType().getRawType()) && (fieldMap.getDestination().getType().isPrimitive() || fieldMap.getDestination().getType().isPrimitiveWrapper()); }
private Type<?> primitiveSafeListType(Type<?> type) { if (type.isPrimitive()) { return type.getWrapperType(); } else { return type; } }
public boolean apply(FieldMap fieldMap) { return String.class.equals(fieldMap.getSource().getType().getRawType()) && (fieldMap.getDestination().getType().isPrimitive() || fieldMap.getDestination().getType().isPrimitiveWrapper()); }
private static Type<?> getObjectType(Type<?> type) { return (type.isPrimitive() ? type.getWrapperType() : type); }
public boolean apply(FieldMap fieldMap) { return String.class.equals(fieldMap.getSource().getType().getRawType()) && (fieldMap.getDestination().getType().isPrimitive() || fieldMap.getDestination().getType().isPrimitiveWrapper()); }
public boolean isImmutable() { return isPrimitive() || IMMUTABLE_TYPES.contains(getRawType()) || isEnum(); }
public boolean appliesTo(FieldMap fieldMap) { return String.class.equals(fieldMap.getSource().getType().getRawType()) && (fieldMap.getDestination().getType().isPrimitive() || fieldMap.getDestination().getType().isPrimitiveWrapper()); }
public boolean isPrimitiveFor(final Type<?> wrapper) { return wrapper != null && isPrimitive() && ClassUtil.getPrimitiveType(wrapper.rawType).equals(getRawType()); }
public boolean apply(FieldMap fieldMap) { return fieldMap.getSource().getType().isPrimitive() || fieldMap.getDestination().getType().isPrimitive(); } };
public boolean apply(FieldMap fieldMap) { return fieldMap.getSource().getType().isPrimitive() || fieldMap.getDestination().getType().isPrimitive(); } };
public boolean isConcrete() { return !isInterface() && (isPrimitive() || isArray() || isAbstract()); }
public boolean appliesTo(FieldMap fieldMap) { return (fieldMap.getSource().getType().isPrimitive() && !TypeFactory.TYPE_OF_OBJECT.equals(fieldMap.getDestination().getType())) || fieldMap.getDestination().getType().isPrimitive(); }
public Object convert(Object source, Type<? extends Object> destinationType, MappingContext context) { if (destinationType.isEnum()) { return convertToEnum((String) source, destinationType); } else if (destinationType.isPrimitive()) { return convertToPrimitive((String) source, destinationType); } else { return convertToWrapper((String) source, destinationType); } }
public Object convert(Object source, Type<? extends Object> destinationType) { if (destinationType.isEnum()) { return convertToEnum((String)source, destinationType); } else if (destinationType.isPrimitive()) { return convertToPrimitive((String)source, destinationType); } else { return convertToWrapper((String)source, destinationType); } }
public String generateMappingCode(FieldMap fieldMap, VariableRef source, VariableRef destination, SourceCodeContext code) { final VariableRef arrayVar = destination.elementRef(destination.name()); String newArray = format("%s[] %s = new %s[%s]", destination.elementTypeName(), destination.name(), destination.elementTypeName(), source.size()); String mapArray; if (destination.elementType().isPrimitive()) { mapArray = format("mapArray(%s, asList(%s), %s.class, mappingContext)", arrayVar, source, arrayVar.typeName()); } else { mapArray = format("mapperFacade.mapAsArray(%s, asList(%s), %s, %s, mappingContext)", destination.name(), source, code.usedType(source.elementType()), code.usedType(destination.elementType())); } String mapNull = shouldMapNulls(fieldMap, code) ? format(" else { %s; }", destination.assignIfPossible("null")) : ""; return format(" %s { %s; %s; %s; } %s", source.ifNotNull(), newArray, mapArray, destination.assign(arrayVar), mapNull); }
private String addAllByAssign(VariableRef value) { if (isArray() && value.isCollection()) { if (type().getComponentType().isPrimitive()) { return assign("%sArray(%s)", type().getComponentType().getCanonicalName(), value); } else { return assign("listToArray(%s, %s.class)", value, type().getCanonicalName()); } } else if (isMap() && value.isList() && isAssignable()) { return assign("listToMap(%s, java.util.LinkedHashMap.class)", value); } return null; }