Class TypeFactory
- java.lang.Object
-
- org.mapstruct.ap.internal.model.common.TypeFactory
-
-
Constructor Summary
Constructors Constructor Description TypeFactory(ElementUtils elementUtils, TypeUtils typeUtils, FormattingMessager messager, RoundContext roundContext, Map<String,String> notToBeImportedTypes, boolean loggingVerbose, VersionInformation versionInformation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BuilderType
builderTypeFor(Type type, org.mapstruct.ap.internal.gem.BuilderGem builder)
Type
classTypeOf(Type type)
Returns the Type that represents the declared Class type of the given type.Type
createVoidType()
creates a void return typeType
effectiveResultTypeFor(Type type, org.mapstruct.ap.internal.gem.BuilderGem builder)
Type
getAlwaysImportedType(TypeMirror mirror)
Return a type that is always going to be imported.TypeMirror
getMethodType(DeclaredType includingType, Element method)
Get the Type for given method as part of usedMapper.ExecutableType
getMethodType(DeclaredType includingType, ExecutableElement method)
Get the ExecutableType for given method as part of usedMapper.List<Parameter>
getParameters(DeclaredType includingType, ExecutableElement method)
List<Parameter>
getParameters(DeclaredType includingType, Accessor accessor)
List<Parameter>
getParameters(ExecutableType methodType, ExecutableElement method)
Type
getReturnType(DeclaredType includingType, Accessor accessor)
Type
getReturnType(ExecutableType method)
Parameter
getSingleParameter(DeclaredType includingType, Accessor method)
List<Type>
getThrownTypes(ExecutableType method)
List<Type>
getThrownTypes(Accessor accessor)
Type
getType(Class<?> type)
Type
getType(String canonicalName)
Type
getType(TypeElement typeElement)
Type
getType(TypeMirror mirror)
TypeMirror
getTypeBound(TypeMirror typeMirror)
Establishes the type bound:<? extends Number>
, returns Number<? super Number>
, returns Number<?>
, returns Object<T extends Number>, returns Number
Type
getTypeForLiteral(Class<?> type)
Type
getWrappedType(Type type)
boolean
isTypeAvailable(String canonicalName)
Determines if the type with the given full qualified name is part of the classpath
-
-
-
Constructor Detail
-
TypeFactory
public TypeFactory(ElementUtils elementUtils, TypeUtils typeUtils, FormattingMessager messager, RoundContext roundContext, Map<String,String> notToBeImportedTypes, boolean loggingVerbose, VersionInformation versionInformation)
-
-
Method Detail
-
isTypeAvailable
public boolean isTypeAvailable(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(TypeElement typeElement)
-
getType
public Type getType(TypeMirror mirror)
-
getAlwaysImportedType
public Type getAlwaysImportedType(TypeMirror mirror)
Return a type that is always going to be imported. This is useful when using it inMapper#imports
for types that should be used in expressions.- Parameters:
mirror
- the type mirror for which we need a type- Returns:
- the type
-
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 ExecutableType getMethodType(DeclaredType includingType, 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 theExecutableElement
directly.- 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 TypeMirror getMethodType(DeclaredType includingType, 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(DeclaredType includingType, Accessor method)
-
getParameters
public List<Parameter> getParameters(DeclaredType includingType, Accessor accessor)
-
getParameters
public List<Parameter> getParameters(DeclaredType includingType, ExecutableElement method)
-
getParameters
public List<Parameter> getParameters(ExecutableType methodType, ExecutableElement method)
-
getReturnType
public Type getReturnType(DeclaredType includingType, Accessor accessor)
-
getReturnType
public Type getReturnType(ExecutableType method)
-
getThrownTypes
public List<Type> getThrownTypes(ExecutableType method)
-
createVoidType
public Type createVoidType()
creates a void return type- Returns:
- void type
-
getTypeBound
public TypeMirror getTypeBound(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
-
builderTypeFor
public BuilderType builderTypeFor(Type type, org.mapstruct.ap.internal.gem.BuilderGem builder)
-
-