public boolean canConvert(Type<?> sourceType, Type<?> destinationType) { return (sourceType.isImmutable() && (sourceType.equals(destinationType) || sourceType.isWrapperFor(destinationType) || destinationType.isWrapperFor(sourceType))); }
if (resolvedType.isConcrete() && !resolvedType.isImmutable()) { synchronized (resolvedType) { Map<Constructor<?>, List<Property>> constructors = new ConcurrentHashMap<Constructor<?>, List<Property>>();
public boolean apply(FieldMap fieldMap) { return fieldMap.getSource().getType().isImmutable() && fieldMap.getDestination().isAssignableFrom(fieldMap.getSource()); } };
Property owningProperty = entry.getValue(); Type<?> propertyType = owningProperty.getType(); if (!propertyType.isImmutable()) { Map<String, Property> props = propertyResolver.getProperties(propertyType); if (propertyType.isMap()) {
public boolean appliesTo(FieldMap fieldMap) { return fieldMap.getSource().getType().isImmutable() && fieldMap.getDestination().isAssignableFrom(fieldMap.getSource()); }
StringBuilder closing = new StringBuilder(); if (destination.isAssignable() || destination.type().isMultiOccurrence() || !destination.type().isImmutable()) {
/** * Resolves whether the given mapping operation can use copy-by-reference * semantics; should be true if one of the following is true: * <ol> * <li>resolvedSourceType and destinationType are the same, and one of the * immutable types * <li>resolvedSourceType is the primitive wrapper for destinationType * <li>resolvedSourceType is primitive and destinationType is it's primitive * wrapper * </ol> * * @param destinationType * @param resolvedSourceType * @return */ private <D, S> boolean canCopyByReference(final Type<D> destinationType, final Type<S> resolvedSourceType) { if (resolvedSourceType.isImmutable() && (destinationType.isAssignableFrom(resolvedSourceType))) { return true; } else if (resolvedSourceType.isPrimitiveWrapper() && resolvedSourceType.getRawType().equals(ClassUtil.getWrapperType(destinationType.getRawType()))) { return true; } else if (resolvedSourceType.isPrimitive() && destinationType.getRawType().equals(ClassUtil.getWrapperType(resolvedSourceType.getRawType()))) { return true; } else { return false; } }
if (!key.getAType().isImmutable() && !key.getBType().isImmutable() && !mapperFactory.existsRegisteredMapper(key.getAType(), key.getBType(), true) && mapperFactory.getClassMap(key) == null) {
private boolean mapFields(Node currentNode, Node srcNode, StringBuilder out, SourceCodeContext code) { VariableRef s = makeVariable(currentNode.value.getSource(), srcNode, "source"); VariableRef d = makeVariable(currentNode.value.getDestination(), currentNode, "destination"); String mapStmt = statement(code.mapFields(currentNode.value, s, d)); VariableRef elRef = currentNode.parent != null ? currentNode.parent.elementRef : null; if (elRef != null && !elRef.isPrimitive() && !elRef.type().isImmutable() && srcNode.parent != null) { // assure instance exists for the element reference append(out, format("if((%s)) { \n", elRef.isNull()), elRef.assign(code.newObject(srcNode.parent.elementRef, elRef.type())), "}"); } out.append(mapStmt); Type<?> parentElementType = currentNode.parent != null ? currentNode.parent.elementRef.type() : TypeFactory.TYPE_OF_OBJECT; return d.type().equals(parentElementType) && mapperFactory.getConverterFactory().canConvert(s.type(), d.type()); }
public boolean apply(FieldMap fieldMap) { return fieldMap.getSource().isMapKey() && (fieldMap.getDestination().getType().isImmutable() || (!fieldMap.getDestination().isCollection() && !fieldMap.getDestination().isArray() && !fieldMap.getDestination().isMap() && !fieldMap.getDestination() .isEnum())); } };
public boolean apply(FieldMap fieldMap) { return fieldMap.getDestination().isMapKey() && (fieldMap.getSource().getType().isImmutable() || (!fieldMap.getSource().isCollection() && !fieldMap.getSource().isArray() && !fieldMap.getSource().isMap() && !fieldMap.getSource().isEnum())); } };
|| currentNode.elementRef.type().isImmutable()) {
public boolean apply(FieldMap fieldMap) { return (fieldMap.getSource().isListElement() || fieldMap.getSource().isArrayElement()) && (fieldMap.getDestination().getType().isImmutable() || (!fieldMap.getDestination().isCollection() && !fieldMap.getDestination().isArray() && !fieldMap.getDestination().isMap() && !fieldMap.getDestination() .isEnum())); } };
public boolean apply(FieldMap fieldMap) { return (fieldMap.getDestination().isListElement() || fieldMap.getDestination().isArrayElement()) && (fieldMap.getSource().getType().isImmutable() || (!fieldMap.getSource().isCollection() && !fieldMap.getSource().isArray() && !fieldMap.getSource().isMap() && !fieldMap.getSource().isEnum())); } };
private String generateFieldMapCode(SourceCodeContext code, FieldMap fieldMap, ClassMap<?, ?> classMap, VariableRef destination, StringBuilder logDetails) throws Exception { final VariableRef sourceProperty = new VariableRef(fieldMap.getSource(), "source"); final VariableRef destinationProperty = new VariableRef(fieldMap.getDestination(), "destination"); destinationProperty.setOwner(destination); if (!sourceProperty.isReadable() || ((!destinationProperty.isAssignable()) && destinationProperty.type().isImmutable())) { if (logDetails != null) { code.debugField(fieldMap, "excluding because "); if (!sourceProperty.isReadable()) { Type<?> sourceType = classMap.getAType().equals(destination.type()) ? classMap.getBType() : classMap.getAType(); logDetails.append(sourceType + "." + fieldMap.getSource().getName() + "(" + fieldMap.getSource().getType() + ") is not readable"); } else { logDetails.append(destination.type() + "." + fieldMap.getDestination().getName() + "(" + fieldMap.getDestination().getType() + ") is not assignable and cannot be mapped in-place"); } } return ""; } // Make sure the source and destination types are accessible to the // builder compilerStrategy.assureTypeIsAccessible(sourceProperty.rawType()); compilerStrategy.assureTypeIsAccessible(destinationProperty.rawType()); return code.mapFields(fieldMap, sourceProperty, destinationProperty); }
if (mapperKey.getBType().isImmutable() && !objectFactoryRegistry.containsKey(mapperKey.getBType())) { throw new MappingException("No converter registered for conversion from " + mapperKey.getAType() + " to " + mapperKey.getBType() + ", nor any ObjectFactory which can generate " + mapperKey.getBType()