All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mapstruct.ap.internal.model.AnnotatedSetter Maven / Gradle / Ivy

There is a newer version: 1.6.3
Show newest version
/*
 * Copyright MapStruct Authors.
 *
 * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
 */
package org.mapstruct.ap.internal.model;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.mapstruct.ap.internal.model.common.Type;

/**
 * @author Lucas Resch
 */
public class AnnotatedSetter extends GeneratedTypeMethod {

    private final Field field;
    private final Collection methodAnnotations;
    private final Collection parameterAnnotations;

    public AnnotatedSetter(Field field, Collection methodAnnotations,
                           Collection parameterAnnotations) {
        this.field = field;
        this.methodAnnotations = methodAnnotations;
        this.parameterAnnotations = parameterAnnotations;
    }

    @Override
    public Set getImportTypes() {
        Set importTypes = new HashSet<>( field.getImportTypes() );
        for ( Annotation annotation : methodAnnotations ) {
            importTypes.addAll( annotation.getImportTypes() );
        }

        for ( Annotation annotation : parameterAnnotations ) {
            importTypes.addAll( annotation.getImportTypes() );
        }

        return importTypes;
    }

    public Type getType() {
        return field.getType();
    }

    public String getFieldName() {
        return field.getVariableName();
    }

    public Collection getMethodAnnotations() {
        return methodAnnotations;
    }

    public Collection getParameterAnnotations() {
        return parameterAnnotations;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy