Class QualifierSelector
- java.lang.Object
-
- org.mapstruct.ap.internal.model.source.selector.QualifierSelector
-
- All Implemented Interfaces:
MethodSelector
public class QualifierSelector extends java.lang.Object implements MethodSelector
This selector selects a best match based on qualifier annotations.A method is said to be marked with a qualifier annotation if the class in which it resides is annotated with a qualifier annotation or if the method itself is annotated with a qualifier annotation or both.
Rules:
- If no qualifiers are requested in the selection criteria, then only candidate methods without any qualifier annotations remain in the list of potential candidates
- If multiple qualifiers (qualifedBy) are specified, then all of them need to be present at a candidate for it to match.
- If no candidate matches the required qualifiers, then all candidates are returned.
-
-
Field Summary
Fields Modifier and Type Field Description private javax.lang.model.type.TypeMirrornamedAnnotationTypeMirrorprivate TypeUtilstypeUtils
-
Constructor Summary
Constructors Constructor Description QualifierSelector(TypeUtils typeUtils, ElementUtils elementUtils)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddOnlyWhenQualifier(java.util.Set<javax.lang.model.element.AnnotationMirror> annotationSet, javax.lang.model.element.AnnotationMirror candidate)<T extends Method>
java.util.List<SelectedMethod<T>>getMatchingMethods(Method mappingMethod, java.util.List<SelectedMethod<T>> methods, java.util.List<Type> sourceTypes, Type mappingTargetType, Type returnType, SelectionCriteria criteria)Selects those methods which match the given types and other criteriaprivate java.util.Set<javax.lang.model.element.AnnotationMirror>getQualifierAnnotationMirrors(Method candidate)
-
-
-
Field Detail
-
typeUtils
private final TypeUtils typeUtils
-
namedAnnotationTypeMirror
private final javax.lang.model.type.TypeMirror namedAnnotationTypeMirror
-
-
Constructor Detail
-
QualifierSelector
public QualifierSelector(TypeUtils typeUtils, ElementUtils elementUtils)
-
-
Method Detail
-
getMatchingMethods
public <T extends Method> java.util.List<SelectedMethod<T>> getMatchingMethods(Method mappingMethod, java.util.List<SelectedMethod<T>> methods, java.util.List<Type> sourceTypes, Type mappingTargetType, Type returnType, SelectionCriteria criteria)
Description copied from interface:MethodSelectorSelects those methods which match the given types and other criteria- Specified by:
getMatchingMethodsin interfaceMethodSelector- Type Parameters:
T- either SourceMethod or BuiltInMethod- Parameters:
mappingMethod- mapping method, defined in Mapper for which this selection is carried outmethods- list of available methodssourceTypes- parameter type(s) that should be matchedmappingTargetType- mappingTargetType that should be matchedreturnType- return type that should be matchedcriteria- criteria used in the selection process- Returns:
- list of methods that passes the matching process
-
getQualifierAnnotationMirrors
private java.util.Set<javax.lang.model.element.AnnotationMirror> getQualifierAnnotationMirrors(Method candidate)
-
addOnlyWhenQualifier
private void addOnlyWhenQualifier(java.util.Set<javax.lang.model.element.AnnotationMirror> annotationSet, javax.lang.model.element.AnnotationMirror candidate)
-
-