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

org.mapstruct.ap.internal.model.AnnotationMapperReference 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.HashSet;
import java.util.List;
import java.util.Set;

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

/**
 * Mapper reference which is retrieved via Annotation-based dependency injection.
* The dependency injection may vary between field and constructor injection. Thus, it is possible to define, whether to * include annotations on the field. * * @author Gunnar Morling * @author Andreas Gudian * @author Kevin Grüneberg */ public class AnnotationMapperReference extends MapperReference { private final List annotations; private final boolean fieldFinal; private final boolean includeAnnotationsOnField; public AnnotationMapperReference(Type type, String variableName, List annotations, boolean isUsed, boolean fieldFinal, boolean includeAnnotationsOnField) { super( type, variableName, isUsed ); this.annotations = annotations; this.fieldFinal = fieldFinal; this.includeAnnotationsOnField = includeAnnotationsOnField; } public List getAnnotations() { return annotations; } @Override public Set getImportTypes() { Set types = new HashSet<>(); types.add( getType() ); for ( Annotation annotation : annotations ) { types.addAll( annotation.getImportTypes() ); } return types; } public boolean isFieldFinal() { return fieldFinal; } public boolean isIncludeAnnotationsOnField() { return includeAnnotationsOnField; } public AnnotationMapperReference withNewAnnotations(List annotations) { return new AnnotationMapperReference( getType(), getVariableName(), annotations, isUsed(), isFieldFinal(), isIncludeAnnotationsOnField() ); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy