Package org.mapstruct.ap.model.assignment

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


                );
                ctx.getMessager().printMessage( Diagnostic.Kind.ERROR, message, method.getExecutable() );
            }

            // target accessor is setter, so decorate assignment as setter
            assignment = new SetterWrapper( assignment, method.getThrownTypes() );

            MethodReference factoryMethod = AssignmentFactory.createFactoryMethod( method.getReturnType(), ctx );
            return new IterableMappingMethod( method, assignment, factoryMethod );
        }
View Full Code Here


                        // mapping method. Note, typeconversons do not apply to collections or maps
                        Assignment newCollectionOrMap = null;
                        if ( assignment.getType() == DIRECT ) {
                            newCollectionOrMap =
                                new NewCollectionOrMapWrapper( assignment, targetType.getImportTypes() );
                            newCollectionOrMap = new SetterWrapper( newCollectionOrMap, method.getThrownTypes() );
                        }

                        // wrap the assignment in the setter method
                        assignment = new SetterWrapper( assignment, method.getThrownTypes() );

                        // target accessor is setter, so wrap the setter in setter map/ collection handling
                        assignment = new SetterCollectionOrMapWrapper(
                            assignment,
                            targetAccessor.getSimpleName().toString(),
                            newCollectionOrMap
                        );
                    }
                    else {
                        // wrap the assignment in the setter method
                        assignment = new SetterWrapper( assignment, method.getThrownTypes() );

                        // target accessor is getter, so wrap the setter in getter map/ collection handling
                        assignment = new GetterCollectionOrMapWrapper( assignment );
                    }

                    // 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 );
                        }
                    }
                }
            }
View Full Code Here

            );

            if ( assignment != null ) {

                // target accessor is setter, so decorate assignment as setter
                assignment = new SetterWrapper( assignment, method.getThrownTypes() );

                // wrap when dealing with getter only on target
                if ( Executables.isGetterMethod( targetAccessor ) ) {
                    assignment = new GetterCollectionOrMapWrapper( assignment );
                }
View Full Code Here

        }

        public PropertyMapping build() {

            Assignment assignment = AssignmentFactory.createDirect( javaExpression );
            assignment = new SetterWrapper( assignment, method.getThrownTypes() );

            Type targetType;
            if ( Executables.isSetterMethod( targetAccessor ) ) {
                targetType = ctx.getTypeFactory().getSingleParameter( targetAccessor ).getType();
            }
View Full Code Here

TOP

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

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.