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,
TypeMirror typeMirror,
TypeElement typeElement,
List<Type> typeParameters,
Type implementationType,
Type componentType,
String packageName,
String name,
String qualifiedName,
boolean isInterface,
boolean isEnumType,
boolean isIterableType,
boolean isCollectionType,
boolean isMapType,
boolean isImported) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canAccess(Type type,
ExecutableElement method)
Whether this type can access the given method declared on the given type.
|
int |
compareTo(Type o) |
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()
Returns this type's enum constants in case it is an enum, an empty list otherwise.
|
String |
getFullyQualifiedName() |
Type |
getImplementationType()
Returns the implementation type to be instantiated in case this type is an interface iterable, collection or map
type.
|
String |
getImportName()
The name of this type as to be used within import statements.
|
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()
A valid Java expression most suitable for representing null - useful for dealing with primitives from FTL.
|
String |
getPackageName() |
Map<String,ExecutableElement> |
getPropertyReadAccessors()
getPropertyReadAccessors
|
Map<String,ExecutableElement> |
getPropertyWriteAccessors(org.mapstruct.ap.prism.CollectionMappingStrategyPrism cmStrategy)
getPropertyWriteAccessors returns a map of the write accessors according to the CollectionMappingStrategy.
|
TypeElement |
getTypeElement() |
TypeMirror |
getTypeMirror() |
List<Type> |
getTypeParameters() |
int |
hashCode() |
boolean |
isAnnotatedWith(String annotationTypeName) |
boolean |
isArrayType() |
boolean |
isAssignableTo(Type other)
Whether this type is assignable to the given other type.
|
boolean |
isCollectionOrMapType() |
boolean |
isCollectionType() |
boolean |
isEnumType() |
boolean |
isImported()
Whether this type is imported by means of an import statement in the currently generated source file (meaning it
can be referenced in the generated source using its simple name) or not (meaning it has to be referenced using
the fully-qualified name).
|
boolean |
isInterface() |
boolean |
isIterableType()
Whether this type is a sub-type of
Iterable or an array type. |
boolean |
isMapType() |
boolean |
isPrimitive() |
boolean |
isVoid() |
String |
toString() |
writegetTemplateNamepublic Type(Types typeUtils, Elements elementUtils, TypeFactory typeFactory, TypeMirror typeMirror, TypeElement typeElement, List<Type> typeParameters, Type implementationType, Type componentType, String packageName, String name, String qualifiedName, boolean isInterface, boolean isEnumType, boolean isIterableType, boolean isCollectionType, boolean isMapType, boolean isImported)
public TypeMirror getTypeMirror()
public TypeElement getTypeElement()
public String getPackageName()
public String getName()
public Type getComponentType()
public boolean isPrimitive()
public boolean isInterface()
public boolean isEnumType()
public boolean isVoid()
public List<String> getEnumConstants()
public Type getImplementationType()
Set<String>, the
implementation type is HashSet<String>.null otherwise.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 isCollectionType()
public boolean isMapType()
public boolean isCollectionOrMapType()
public boolean isArrayType()
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 isImported()
true if the type is imported, false otherwise.public boolean isAnnotatedWith(String annotationTypeName)
annotationTypeName - the fully qualified name of the annotation typepublic Type erasure()
public boolean isAssignableTo(Type other)
other - The other type.true if and only if this type is assignable to the given other type.public Map<String,ExecutableElement> getPropertyReadAccessors()
public Map<String,ExecutableElement> getPropertyWriteAccessors(org.mapstruct.ap.prism.CollectionMappingStrategyPrism cmStrategy)
getSetters()getPropertyReadAccessors()getAdders()cmStrategy - public 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)
public String getNull()
public int compareTo(Type o)
compareTo in interface Comparable<Type>Copyright © 2012-2015. All Rights Reserved.