public class Type extends ModelElement implements Comparable<Type>
TypeMirror, i.e. there are different instances for e.g. Set<String> and
Set<Integer>.
Allows for a unified handling of declared and primitive types and usage within templates. Instances are obtained
through TypeFactory.
Writable.Context| Constructor and Description |
|---|
Type(Types typeUtils,
Elements elementUtils,
TypeFactory typeFactory,
AccessorNamingUtils accessorNaming,
TypeMirror typeMirror,
TypeElement typeElement,
List<Type> typeParameters,
ImplementationType implementationType,
Type componentType,
String packageName,
String name,
String qualifiedName,
boolean isInterface,
boolean isEnumType,
boolean isIterableType,
boolean isCollectionType,
boolean isMapType,
boolean isStreamType,
Map<String,String> toBeImportedTypes,
Map<String,String> notToBeImportedTypes,
Boolean isToBeImported,
boolean isLiteral,
boolean loggingVerbose) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canAccess(Type type,
ExecutableElement method) |
int |
compareTo(Type o) |
String |
createReferenceName()
Returns a String that could be used in generated code to reference to this
Type. |
String |
describe() |
List<Type> |
determineTypeArguments(Class<?> superclass)
Searches for the given superclass and collects all type arguments for the given class
|
int |
distanceTo(Type assignableOther)
Returns the length of the shortest path in the type hierarchy between this type and the specified other type.
|
boolean |
equals(Object obj) |
Type |
erasure() |
Type |
getComponentType() |
List<String> |
getEnumConstants() |
String |
getFullyQualifiedName() |
String |
getIdentification() |
ImplementationType |
getImplementation() |
Type |
getImplementationType()
Returns the implementation type to be instantiated in case this type is an interface iterable, collection or map
type.
|
String |
getImportName() |
Set<Type> |
getImportTypes()
Returns a set containing those
Types referenced by this model element for which an import statement needs
to be declared. |
String |
getName() |
String |
getNull() |
String |
getPackageName() |
Map<String,Accessor> |
getPropertyPresenceCheckers()
getPropertyPresenceCheckers
|
Map<String,Accessor> |
getPropertyReadAccessors()
getPropertyReadAccessors
|
Map<String,Accessor> |
getPropertyWriteAccessors(org.mapstruct.ap.internal.gem.CollectionMappingStrategyGem cmStrategy)
getPropertyWriteAccessors returns a map of the write accessors according to the CollectionMappingStrategy.
|
List<Element> |
getRecordComponents() |
String |
getSensibleDefault() |
Type |
getTypeBound()
Establishes the type bound:
<? extends Number>, returns Number
<? super Number>, returns Number
<?>, returns Object
<T extends Number>, returns Number
|
TypeElement |
getTypeElement() |
TypeMirror |
getTypeMirror() |
List<Type> |
getTypeParameters() |
boolean |
hasAccessibleConstructor() |
int |
hashCode() |
boolean |
isAbstract() |
boolean |
isArrayType() |
boolean |
isAssignableTo(Type other)
Whether this type is assignable to the given other type.
|
boolean |
isCollectionOrMapType() |
boolean |
isCollectionType() |
boolean |
isEnumType() |
boolean |
isInterface() |
boolean |
isIterableOrStreamType()
|
boolean |
isIterableType()
Whether this type is a sub-type of
Iterable or an array type. |
boolean |
isJavaLangType() |
boolean |
isLiteral() |
boolean |
isMapType() |
boolean |
isNative()
All primitive types and their corresponding boxed types are considered native.
|
boolean |
isPrimitive() |
boolean |
isRawAssignableTo(Type other)
Whether this type is raw assignable to the given other type.
|
boolean |
isRecord() |
boolean |
isStreamType()
Whether this type is a sub-type of
Stream. |
boolean |
isString() |
boolean |
isToBeImported()
Whether this type is to be imported by means of an import statement in the currently generated source file
(it can be referenced in the generated source using its simple name) or not (referenced using the FQN).
|
boolean |
isTypeVar() |
boolean |
isVoid() |
boolean |
isWildCardExtendsBound() |
boolean |
isWildCardSuperBound() |
Type |
resolveTypeVarToType(Type declaredType,
Type parameterizedType)
Steps through the declaredType in order to find a match for this typevar Type.
|
String |
toString() |
Type |
withoutBounds() |
getTemplateName, getTemplateNameForClass, writepublic Type(Types typeUtils, Elements elementUtils, TypeFactory typeFactory, AccessorNamingUtils accessorNaming, TypeMirror typeMirror, TypeElement typeElement, List<Type> typeParameters, ImplementationType implementationType, Type componentType, String packageName, String name, String qualifiedName, boolean isInterface, boolean isEnumType, boolean isIterableType, boolean isCollectionType, boolean isMapType, boolean isStreamType, Map<String,String> toBeImportedTypes, Map<String,String> notToBeImportedTypes, Boolean isToBeImported, boolean isLiteral, boolean loggingVerbose)
public TypeMirror getTypeMirror()
public TypeElement getTypeElement()
public String getPackageName()
public String getName()
public String createReferenceName()
Type.
The first time a name is referred-to it will be marked as to be imported. For instance
LocalDateTime can be one of java.time.LocalDateTime and org.joda.LocalDateTime)
If the java.time variant is referred to first, the java.time.LocalDateTime will be imported
and the org.joda variant will be referred to with its FQN.
Type will be imported, otherwise the fully-qualified name.public Type getComponentType()
public boolean isPrimitive()
public boolean isInterface()
public boolean isEnumType()
public boolean isVoid()
public boolean isAbstract()
public boolean isString()
public List<String> getEnumConstants()
public Type getImplementationType()
Set<String>, the
implementation type is HashSet<String>.null otherwise.public ImplementationType getImplementation()
public boolean isIterableType()
Iterable or an array type.true if this type is a sub-type of Iterable or an array type, false otherwise.public boolean isIterableOrStreamType()
public boolean isCollectionType()
public boolean isMapType()
public boolean isCollectionOrMapType()
public boolean isArrayType()
public boolean isTypeVar()
public boolean isJavaLangType()
public boolean isRecord()
public boolean isStreamType()
Stream.true it this type is a sub-type of Stream, false otherwisepublic boolean isWildCardSuperBound()
public boolean isWildCardExtendsBound()
public String getFullyQualifiedName()
public String getImportName()
public Set<Type> getImportTypes()
ModelElementTypes referenced by this model element for which an import statement needs
to be declared.getImportTypes in class ModelElementnull.public boolean isToBeImported()
true if the type is imported, false otherwise.public Type erasure()
public Type withoutBounds()
public boolean isAssignableTo(Type other)
other - The other type.true if and only if this type is assignable to the given other type.public boolean isRawAssignableTo(Type other)
other - The other type.true if and only if this type is assignable to the given other type.public Map<String,Accessor> getPropertyReadAccessors()
public Map<String,Accessor> getPropertyPresenceCheckers()
public Map<String,Accessor> getPropertyWriteAccessors(org.mapstruct.ap.internal.gem.CollectionMappingStrategyGem cmStrategy)
getSetters()getPropertyReadAccessors()getAdders()cmStrategy - collection mapping strategypublic int distanceTo(Type assignableOther)
-1 if this type is not assignable to the other type. Returns 0 if this type is equal to
the other type. Returns 1, if the other type is a direct super type of this type, and so on.assignableOther - the other typepublic boolean canAccess(Type type, ExecutableElement method)
type - the type declaring the methodmethod - the method to checkpublic String getNull()
public String getSensibleDefault()
public int compareTo(Type o)
compareTo in interface Comparable<Type>public String describe()
public String getIdentification()
public Type getTypeBound()
<? extends Number>, returns Number<? super Number>, returns Number<?>, returns Object<T extends Number>, returns Numberpublic boolean hasAccessibleConstructor()
public List<Type> determineTypeArguments(Class<?> superclass)
superclass - the superclass or interface the generic type arguments are searched forpublic boolean isNative()
public boolean isLiteral()
public Type resolveTypeVarToType(Type declaredType, Type parameterizedType)
declaredType - the typeparameterizedType - the parameterized typeCopyright © 2012–2020. All rights reserved.