Class TypeFactory
- java.lang.Object
-
- org.mapstruct.ap.internal.model.common.TypeFactory
-
public class TypeFactory extends java.lang.ObjectFactory creatingTypeinstances.
-
-
Field Summary
Fields Modifier and Type Field Description private static Extractor<BuilderInfo,java.lang.String>BUILDER_INFO_CREATION_METHOD_EXTRACTORprivate javax.lang.model.type.TypeMirrorcollectionTypeprivate ElementUtilselementUtilsprivate java.util.Map<java.lang.String,ImplementationType>implementationTypesprivate javax.lang.model.type.TypeMirroriterableTypeprivate booleanloggingVerboseprivate javax.lang.model.type.TypeMirrormapTypeprivate FormattingMessagermessagerprivate java.util.Map<java.lang.String,java.lang.String>notToBeImportedTypesprivate RoundContextroundContextprivate javax.lang.model.type.TypeMirrorstreamTypeprivate java.util.Map<java.lang.String,java.lang.String>toBeImportedTypesprivate TypeUtilstypeUtils
-
Constructor Summary
Constructors Constructor Description TypeFactory(ElementUtils elementUtils, TypeUtils typeUtils, FormattingMessager messager, RoundContext roundContext, java.util.Map<java.lang.String,java.lang.String> notToBeImportedTypes, boolean loggingVerbose)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BuilderTypebuilderTypeFor(Type type, BuilderGem builder)private booleancanBeProcessed(javax.lang.model.type.TypeMirror type)Whether the given type is ready to be processed or not.TypeclassTypeOf(Type type)Returns the Type that represents the declared Class type of the given type.TypecreateVoidType()creates a void return typeTypeeffectiveResultTypeFor(Type type, BuilderGem builder)private java.util.List<Type>extractTypes(java.util.List<? extends javax.lang.model.type.TypeMirror> typeMirrors)private BuilderInfofindBuilder(javax.lang.model.type.TypeMirror type, BuilderGem builderGem, boolean report)TypegetAlwaysImportedType(javax.lang.model.type.TypeMirror mirror)Return a type that is always going to be imported.private javax.lang.model.type.TypeMirrorgetComponentType(javax.lang.model.type.TypeMirror mirror)private ImplementationTypegetImplementationType(javax.lang.model.type.TypeMirror mirror)javax.lang.model.type.TypeMirrorgetMethodType(javax.lang.model.type.DeclaredType includingType, javax.lang.model.element.Element method)Get the Type for given method as part of usedMapper.javax.lang.model.type.ExecutableTypegetMethodType(javax.lang.model.type.DeclaredType includingType, javax.lang.model.element.ExecutableElement method)Get the ExecutableType for given method as part of usedMapper.java.util.List<Parameter>getParameters(javax.lang.model.type.DeclaredType includingType, javax.lang.model.element.ExecutableElement method)java.util.List<Parameter>getParameters(javax.lang.model.type.DeclaredType includingType, Accessor accessor)java.util.List<Parameter>getParameters(javax.lang.model.type.ExecutableType methodType, javax.lang.model.element.ExecutableElement method)private javax.lang.model.type.TypeMirrorgetPrimitiveType(java.lang.Class<?> primitiveType)TypegetReturnType(javax.lang.model.type.DeclaredType includingType, Accessor accessor)TypegetReturnType(javax.lang.model.type.ExecutableType method)ParametergetSingleParameter(javax.lang.model.type.DeclaredType includingType, Accessor method)java.util.List<Type>getThrownTypes(javax.lang.model.type.ExecutableType method)java.util.List<Type>getThrownTypes(Accessor accessor)TypegetType(java.lang.Class<?> type)TypegetType(java.lang.String canonicalName)private TypegetType(java.lang.String canonicalName, boolean isLiteral)TypegetType(javax.lang.model.element.TypeElement typeElement)private TypegetType(javax.lang.model.element.TypeElement typeElement, boolean isLiteral)TypegetType(javax.lang.model.type.TypeMirror mirror)private TypegetType(javax.lang.model.type.TypeMirror mirror, boolean isLiteral)private TypegetType(javax.lang.model.type.TypeMirror mirror, boolean isLiteral, java.lang.Boolean alwaysImport)javax.lang.model.type.TypeMirrorgetTypeBound(javax.lang.model.type.TypeMirror typeMirror)Establishes the type bound:<? extends Number>, returns Number<? super Number>, returns Number<?>, returns Object<T extends Number>, returns NumberTypegetTypeForLiteral(java.lang.Class<?> type)private java.util.List<Type>getTypeParameters(javax.lang.model.type.TypeMirror mirror, boolean isImplementationType)TypegetWrappedType(Type type)private booleanisExecutableType(javax.lang.model.type.TypeMirror accessorType)booleanisTypeAvailable(java.lang.String canonicalName)Determines if the type with the given full qualified name is part of the classpath
-
-
-
Field Detail
-
BUILDER_INFO_CREATION_METHOD_EXTRACTOR
private static final Extractor<BuilderInfo,java.lang.String> BUILDER_INFO_CREATION_METHOD_EXTRACTOR
-
elementUtils
private final ElementUtils elementUtils
-
typeUtils
private final TypeUtils typeUtils
-
messager
private final FormattingMessager messager
-
roundContext
private final RoundContext roundContext
-
iterableType
private final javax.lang.model.type.TypeMirror iterableType
-
collectionType
private final javax.lang.model.type.TypeMirror collectionType
-
mapType
private final javax.lang.model.type.TypeMirror mapType
-
streamType
private final javax.lang.model.type.TypeMirror streamType
-
implementationTypes
private final java.util.Map<java.lang.String,ImplementationType> implementationTypes
-
toBeImportedTypes
private final java.util.Map<java.lang.String,java.lang.String> toBeImportedTypes
-
notToBeImportedTypes
private final java.util.Map<java.lang.String,java.lang.String> notToBeImportedTypes
-
loggingVerbose
private final boolean loggingVerbose
-
-
Constructor Detail
-
TypeFactory
public TypeFactory(ElementUtils elementUtils, TypeUtils typeUtils, FormattingMessager messager, RoundContext roundContext, java.util.Map<java.lang.String,java.lang.String> notToBeImportedTypes, boolean loggingVerbose)
-
-
Method Detail
-
getTypeForLiteral
public Type getTypeForLiteral(java.lang.Class<?> type)
-
getType
public Type getType(java.lang.Class<?> type)
-
getType
public Type getType(java.lang.String canonicalName)
-
getType
private Type getType(java.lang.String canonicalName, boolean isLiteral)
-
isTypeAvailable
public boolean isTypeAvailable(java.lang.String canonicalName)
Determines if the type with the given full qualified name is part of the classpath- Parameters:
canonicalName- Name of the type to be checked for availability- Returns:
- true if the type with the given full qualified name is part of the classpath.
-
getType
public Type getType(javax.lang.model.element.TypeElement typeElement)
-
getType
private Type getType(javax.lang.model.element.TypeElement typeElement, boolean isLiteral)
-
getType
public Type getType(javax.lang.model.type.TypeMirror mirror)
-
getAlwaysImportedType
public Type getAlwaysImportedType(javax.lang.model.type.TypeMirror mirror)
Return a type that is always going to be imported. This is useful when using it inMapper#importsfor types that should be used in expressions.- Parameters:
mirror- the type mirror for which we need a type- Returns:
- the type
-
getType
private Type getType(javax.lang.model.type.TypeMirror mirror, boolean isLiteral)
-
getType
private Type getType(javax.lang.model.type.TypeMirror mirror, boolean isLiteral, java.lang.Boolean alwaysImport)
-
classTypeOf
public Type classTypeOf(Type type)
Returns the Type that represents the declared Class type of the given type. For primitive types, the boxed class will be used. Examples:- If type represents
java.lang.Integer, it will return the type that representsClass<Integer>. - If type represents
int, it will return the type that representsClass<Integer>.
- Parameters:
type- the type to return the declared class type for- Returns:
- the type representing
Class<type>.
- If type represents
-
getMethodType
public javax.lang.model.type.ExecutableType getMethodType(javax.lang.model.type.DeclaredType includingType, javax.lang.model.element.ExecutableElement method)Get the ExecutableType for given method as part of usedMapper. Possibly parameterized types in method declaration will be evaluated to concrete types then. IMPORTANT: This should only be used from the Processors, as they are operating over executable elements. The internals should not be using this function and should not be using theExecutableElementdirectly.- Parameters:
includingType- the type on which's scope the method type shall be evaluatedmethod- the method- Returns:
- the ExecutableType representing the method as part of usedMapper
-
getMethodType
public javax.lang.model.type.TypeMirror getMethodType(javax.lang.model.type.DeclaredType includingType, javax.lang.model.element.Element method)Get the Type for given method as part of usedMapper. Possibly parameterized types in method declaration will be evaluated to concrete types then.- Parameters:
includingType- the type on which's scope the method type shall be evaluatedmethod- the method- Returns:
- the ExecutableType representing the method as part of usedMapper
-
getSingleParameter
public Parameter getSingleParameter(javax.lang.model.type.DeclaredType includingType, Accessor method)
-
getParameters
public java.util.List<Parameter> getParameters(javax.lang.model.type.DeclaredType includingType, Accessor accessor)
-
getParameters
public java.util.List<Parameter> getParameters(javax.lang.model.type.DeclaredType includingType, javax.lang.model.element.ExecutableElement method)
-
getParameters
public java.util.List<Parameter> getParameters(javax.lang.model.type.ExecutableType methodType, javax.lang.model.element.ExecutableElement method)
-
getReturnType
public Type getReturnType(javax.lang.model.type.DeclaredType includingType, Accessor accessor)
-
isExecutableType
private boolean isExecutableType(javax.lang.model.type.TypeMirror accessorType)
-
getReturnType
public Type getReturnType(javax.lang.model.type.ExecutableType method)
-
getThrownTypes
public java.util.List<Type> getThrownTypes(javax.lang.model.type.ExecutableType method)
-
extractTypes
private java.util.List<Type> extractTypes(java.util.List<? extends javax.lang.model.type.TypeMirror> typeMirrors)
-
getTypeParameters
private java.util.List<Type> getTypeParameters(javax.lang.model.type.TypeMirror mirror, boolean isImplementationType)
-
getPrimitiveType
private javax.lang.model.type.TypeMirror getPrimitiveType(java.lang.Class<?> primitiveType)
-
getImplementationType
private ImplementationType getImplementationType(javax.lang.model.type.TypeMirror mirror)
-
findBuilder
private BuilderInfo findBuilder(javax.lang.model.type.TypeMirror type, BuilderGem builderGem, boolean report)
-
getComponentType
private javax.lang.model.type.TypeMirror getComponentType(javax.lang.model.type.TypeMirror mirror)
-
createVoidType
public Type createVoidType()
creates a void return type- Returns:
- void type
-
getTypeBound
public javax.lang.model.type.TypeMirror getTypeBound(javax.lang.model.type.TypeMirror typeMirror)
Establishes the type bound:<? extends Number>, returns Number<? super Number>, returns Number<?>, returns Object<T extends Number>, returns Number
- Parameters:
typeMirror- the type to return the bound for- Returns:
- the bound for this parameter
-
canBeProcessed
private boolean canBeProcessed(javax.lang.model.type.TypeMirror type)
Whether the given type is ready to be processed or not. It can be processed if it is not of kindTypeKind.ERRORand allAstModifyingAnnotationProcessors (if any) indicated that they've fully processed the type.
-
builderTypeFor
public BuilderType builderTypeFor(Type type, BuilderGem builder)
-
effectiveResultTypeFor
public Type effectiveResultTypeFor(Type type, BuilderGem builder)
-
-