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) |
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() |
String |
getFullyQualifiedName() |
String |
getIdentification() |
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
Type s referenced by this model element for which an import statement needs
to be declared. |
String |
getName() |
String |
getNull() |
String |
getPackageName() |
Map<String,ExecutableElement> |
getPropertyReadAccessors()
getPropertyReadAccessors
|
Map<String,ExecutableElement> |
getPropertyWriteAccessors(org.mapstruct.ap.internal.prism.CollectionMappingStrategyPrism cmStrategy)
getPropertyWriteAccessors returns a map of the write accessors according to the CollectionMappingStrategy.
|
Type |
getTypeBound()
Establishes the type bound:
{@code
|
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 |
isTypeVar() |
boolean |
isVoid() |
boolean |
isWildCardExtendsBound() |
boolean |
isWildCardSuperBound() |
String |
toString() |
write
getTemplateName, getTemplateNameForClass
public 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 boolean isTypeVar()
public boolean isWildCardSuperBound()
public boolean isWildCardExtendsBound()
public String getFullyQualifiedName()
public String getImportName()
public Set<Type> getImportTypes()
ModelElement
Type
s referenced by this model element for which an import statement needs
to be declared.getImportTypes
in class ModelElement
null
.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.internal.prism.CollectionMappingStrategyPrism 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 int compareTo(Type o)
compareTo
in interface Comparable<Type>
public String getIdentification()
public Type getTypeBound()
Copyright © 2012-2015 Gunnar Morling; All rights reserved. Released under the Apache Software License 2.0.