// For collections and maps include a null check, when the assignment type is DIRECT.
// for mapping methods (builtin / custom), the mapping method is responsible for the
// null check. Typeconversions do not apply to collections and maps.
if ( assignment.getType() == DIRECT ) {
assignment = new NullCheckWrapper( assignment );
}
}
else {
if ( targetAccessorType == TargetAccessorType.SETTER ) {
assignment = new SetterWrapper( assignment, method.getThrownTypes() );
if ( !sourceType.isPrimitive()
&& ( assignment.getType() == TYPE_CONVERTED
|| assignment.getType() == TYPE_CONVERTED_MAPPED
|| assignment.getType() == DIRECT && targetType.isPrimitive() ) ) {
// for primitive types null check is not possible at all, but a conversion needs
// a null check.
assignment = new NullCheckWrapper( assignment );
}
}
else {
// TargetAccessorType must be ADDER
if ( getSourceType().isCollectionType() ) {
assignment = new AdderWrapper(
assignment,
method.getThrownTypes(),
getSourceRef(),
sourceType
);
}
else {
// Possibly adding null to a target collection. So should be surrounded by an null check.
assignment = new SetterWrapper( assignment, method.getThrownTypes() );
assignment = new NullCheckWrapper( assignment );
}
}
}
}
else {