public class Type extends ModelElement implements java.lang.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(javax.lang.model.util.Types typeUtils,
javax.lang.model.util.Elements elementUtils,
javax.lang.model.type.TypeMirror typeMirror,
javax.lang.model.element.TypeElement typeElement,
java.util.List<Type> typeParameters,
Type implementationType,
java.lang.String packageName,
java.lang.String name,
java.lang.String qualifiedName,
boolean isInterface,
boolean isEnumType,
boolean isIterableType,
boolean isCollectionType,
boolean isMapType,
boolean isImported) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canAccess(Type type,
javax.lang.model.element.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(java.lang.Object obj) |
Type |
erasure() |
javax.lang.model.element.ExecutableElement |
getAdderForType(Type collectionProperty,
java.lang.String pluralPropertyName)
Tries to find an addMethod in this type for given collection property in this type.
|
java.util.List<javax.lang.model.element.ExecutableElement> |
getAlternativeTargetAccessors()
Alternative accessors could be a getter for a collection.
|
java.util.List<java.lang.String> |
getEnumConstants()
Returns this type's enum constants in case it is an enum, an empty list otherwise.
|
java.lang.String |
getFullyQualifiedName() |
java.util.List<javax.lang.model.element.ExecutableElement> |
getGetters()
getGetters
|
Type |
getImplementationType()
Returns the implementation type to be instantiated in case this type is an interface iterable, collection or map
type.
|
java.util.Set<Type> |
getImportTypes()
Returns a set containing those
Types referenced by this model element for which an import statement needs
to be declared. |
java.lang.String |
getName() |
java.lang.String |
getPackageName() |
java.util.List<javax.lang.model.element.ExecutableElement> |
getSetters()
getSetters
|
javax.lang.model.element.TypeElement |
getTypeElement() |
javax.lang.model.type.TypeMirror |
getTypeMirror() |
java.util.List<Type> |
getTypeParameters() |
int |
hashCode() |
boolean |
isAnnotatedWith(java.lang.String annotationTypeName) |
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() |
boolean |
isMapType() |
boolean |
isPrimitive() |
java.lang.String |
toString() |
writegetTemplateNamepublic Type(javax.lang.model.util.Types typeUtils,
javax.lang.model.util.Elements elementUtils,
javax.lang.model.type.TypeMirror typeMirror,
javax.lang.model.element.TypeElement typeElement,
java.util.List<Type> typeParameters,
Type implementationType,
java.lang.String packageName,
java.lang.String name,
java.lang.String qualifiedName,
boolean isInterface,
boolean isEnumType,
boolean isIterableType,
boolean isCollectionType,
boolean isMapType,
boolean isImported)
public javax.lang.model.type.TypeMirror getTypeMirror()
public javax.lang.model.element.TypeElement getTypeElement()
public java.lang.String getPackageName()
public java.lang.String getName()
public java.util.List<Type> getTypeParameters()
public boolean isPrimitive()
public boolean isInterface()
public boolean isEnumType()
public java.util.List<java.lang.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 boolean isCollectionOrMapType()
public java.lang.String getFullyQualifiedName()
public java.util.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(java.lang.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 java.util.List<javax.lang.model.element.ExecutableElement> getGetters()
public javax.lang.model.element.ExecutableElement getAdderForType(Type collectionProperty, java.lang.String pluralPropertyName)
collectionProperty - property type (assumed collection) to find the adder method forpluralPropertyName - the property name (assumed plural)public java.util.List<javax.lang.model.element.ExecutableElement> getSetters()
public java.util.List<javax.lang.model.element.ExecutableElement> getAlternativeTargetAccessors()
Collection.addAll(java.util.Collection) this getter can still
be used as targetAccessor. JAXB XJC tool generates such constructs.
This method can be extended when new cases come along.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, javax.lang.model.element.ExecutableElement method)
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int compareTo(Type o)
compareTo in interface java.lang.Comparable<Type>public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2012-2014. All Rights Reserved.