}
private Assignment forgeMapOrIterableMapping(Type sourceType, Type targetType, String sourceReference,
ExecutableElement element) {
Assignment assignment = null;
if ( sourceType.isCollectionType() && targetType.isCollectionType() ) {
ForgedMethod methodToGenerate = new ForgedMethod( sourceType, targetType, element );
IterableMappingMethod.Builder builder = new IterableMappingMethod.Builder();
IterableMappingMethod iterableMappingMethod = builder
.mappingContext( ctx )
.method( methodToGenerate )
.build();
if ( !ctx.getMappingsToGenerate().contains( iterableMappingMethod ) ) {
ctx.getMappingsToGenerate().add( iterableMappingMethod );
}
assignment = AssignmentFactory.createMethodReference( methodToGenerate, null, targetType );
assignment.setAssignment( AssignmentFactory.createDirect( sourceReference ) );
}
else if ( sourceType.isMapType() && targetType.isMapType() ) {
ForgedMethod methodToGenerate = new ForgedMethod( sourceType, targetType, element );
MapMappingMethod.Builder builder = new MapMappingMethod.Builder();
MapMappingMethod mapMappingMethod = builder
.mappingContext( ctx )
.method( methodToGenerate )
.build();
if ( !ctx.getMappingsToGenerate().contains( mapMappingMethod ) ) {
ctx.getMappingsToGenerate().add( mapMappingMethod );
}
assignment = AssignmentFactory.createMethodReference( methodToGenerate, null, targetType );
assignment.setAssignment( AssignmentFactory.createDirect( sourceReference ) );
}
return assignment;
}