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,
TypeMirror typeMirror,
TypeElement typeElement,
List<Type> typeParameters,
Type implementationType,
String packageName,
String name,
String qualifiedName,
boolean isInterface,
boolean isEnumType,
boolean isIterableType,
boolean isCollectionType,
boolean isMapType,
boolean isImported) |
| Modifier and Type | Method and Description |
|---|---|
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() |
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.
|
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 |
getPackageName() |
TypeElement |
getTypeElement() |
TypeMirror |
getTypeMirror() |
List<Type> |
getTypeParameters() |
int |
hashCode() |
boolean |
isAnnotatedWith(String annotationTypeName) |
boolean |
isAssignableTo(Type other)
Whether this type is assignable to the given other type.
|
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() |
boolean |
isMapType() |
boolean |
isPrimitive() |
String |
toString() |
writegetTemplateNamepublic Type(Types typeUtils, TypeMirror typeMirror, TypeElement typeElement, List<Type> typeParameters, Type implementationType, 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 boolean isPrimitive()
public boolean isInterface()
public boolean isEnumType()
public List<String> getEnumConstants()
public Type getImplementationType()
Set<String>, the
implementation type is HashSet<String>.null otherwise.public boolean isIterableType()
public boolean isCollectionType()
public boolean isMapType()
public String getFullyQualifiedName()
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 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 int compareTo(Type o)
compareTo in interface Comparable<Type>Copyright © 2012-2014. All Rights Reserved.