Package org.mapstruct.ap.model.assignment

Examples of org.mapstruct.ap.model.assignment.NullCheckWrapper


                    // 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 {
View Full Code Here

TOP

Related Classes of org.mapstruct.ap.model.assignment.NullCheckWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.