|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.teatrove.tea.compiler.Type
public class Type
Immutable representation of an expression's type.
Expression,
Serialized Form| Field Summary | |
|---|---|
static Type |
BOOLEAN_TYPE
Type for representing booleans, provided as a convenience |
static Type |
INT_TYPE
Type for representing ints, provided as a convenience |
static Type |
LONG_TYPE
Type for representing longs, provided as a convenience |
static Type |
NON_NULL_STRING_TYPE
Type for representing non-null Strings, provided as a convenience |
static Type |
NULL_TYPE
Type that is compatble with all other types |
static Type |
OBJECT_TYPE
Type that represents all objects, provided as a convenience |
static Type |
STRING_TYPE
Type for representing Strings, provided as a convenience |
static Type |
VOID_TYPE
Type that represents void, provided as a convenience |
| Constructor Summary | |
|---|---|
Type(Class<?> type)
|
|
Type(Class<?> type,
Type generic)
|
|
Type(Class<?> type,
TypedElement te)
|
|
Type(Class<?> type,
Type generic,
TypedElement te)
|
|
Type(GenericType type)
|
|
Type(GenericType type,
TypedElement te)
|
|
| Method Summary | |
|---|---|
int |
convertableFrom(Type other)
Returns the conversion cost of assigning the given type to this type. |
boolean |
equals(Object another)
|
static Class<?> |
findCommonBaseClass(Class<?> a,
Class<?> b)
Returns the most specific common superclass or interface that can be used to represent both of the specified classes. |
Method[] |
getArrayAccessMethods()
If this Type supports array lookup, then return all of the methods that can be called to access the array. |
Type |
getArrayElementType()
If this Type supports array lookup, then return the element type. |
Type[] |
getArrayIndexTypes()
If this Type supports array lookup, then return the index type. |
String |
getClassName()
|
Type |
getCompatibleType(Type other)
Returns a type that is compatible with this type, and the one passed in. |
String |
getFullName()
|
Type |
getGenericClass()
Returns the JDK 5 generic type associated with this type. |
GenericType |
getGenericType()
|
Type |
getIterationElementType()
If this type supports iteration, then the element type is returned. |
static Type |
getIterationType(GenericType type)
Get the iteration type of the generic type based on the generic type parameters. |
Type |
getKeyElementType()
|
static Type |
getKeyType(GenericType type)
Get the key type of the generic type based on the generic type parameters. |
Class<?> |
getNaturalClass()
Returns the natural class for this type. |
Class<?> |
getObjectClass()
Class returned never represents a primitive type. |
String |
getSimpleName()
|
protected static Type |
getTypeArgument(GenericType type,
int index)
Get the associated type of the generic type based on the generic type parameters. |
Type |
getValueElementType()
|
static Type |
getValueType(GenericType type)
Get the value type of the generic type based on the generic type parameters. |
int |
hashCode()
|
boolean |
hasPrimitivePeer()
Returns true if this type is not primitive, but it has a primitive type peer. |
boolean |
isNonNull()
Returns true if this type cannot reference null. |
boolean |
isNullable()
Returns true if this type can reference null, or simply the opposite result of isNonNull. |
boolean |
isPrimitive()
Returns true if this type is a primitive. |
boolean |
isReverseIterationSupported()
Returns true if this type supports iteration in the reverse direction. |
boolean |
isVoid()
Return true if this type is void. |
static Type |
preserveType(Type currentType,
Type newType)
Preserve the current type's generic information with the specified new type if they have the same class. |
Type |
setArrayElementType(Type elementType)
Accessed by the TypeChecker, to override the default. |
Type |
toNonNull()
Returns this type converted such that it cannot reference null. |
Type |
toNonPrimitive()
Returns a new type from this one that represents a non-primitive type. |
Type |
toNullable()
Returns this type converted such that it can reference null. |
Type |
toPrimitive()
Returns a new type from this one that represents a primitive type. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Type NULL_TYPE
public static final Type VOID_TYPE
public static final Type OBJECT_TYPE
public static final Type INT_TYPE
public static final Type LONG_TYPE
public static final Type BOOLEAN_TYPE
public static final Type STRING_TYPE
public static final Type NON_NULL_STRING_TYPE
| Constructor Detail |
|---|
public Type(Class<?> type)
public Type(Class<?> type,
Type generic)
public Type(GenericType type)
public Type(Class<?> type,
TypedElement te)
public Type(Class<?> type,
Type generic,
TypedElement te)
public Type(GenericType type,
TypedElement te)
| Method Detail |
|---|
public String getClassName()
public Class<?> getObjectClass()
public GenericType getGenericType()
public Type getGenericClass()
public Class<?> getNaturalClass()
public boolean isVoid()
public boolean isPrimitive()
public boolean hasPrimitivePeer()
public Type toPrimitive()
public Type toNonPrimitive()
public boolean isNonNull()
public boolean isNullable()
public Type toNonNull()
public Type toNullable()
public Type getArrayElementType()
throws IntrospectionException
IntrospectionException
public Type[] getArrayIndexTypes()
throws IntrospectionException
IntrospectionException
public Method[] getArrayAccessMethods()
throws IntrospectionException
IntrospectionException
public Type getIterationElementType()
throws IntrospectionException
IntrospectionException
public Type getKeyElementType()
throws IntrospectionException
IntrospectionException
public Type getValueElementType()
throws IntrospectionException
IntrospectionExceptionpublic boolean isReverseIterationSupported()
public Type setArrayElementType(Type elementType)
throws IntrospectionException
IntrospectionExceptionpublic String getSimpleName()
public String getFullName()
public String toString()
toString in class Objectpublic int hashCode()
hashCode in class Objectpublic boolean equals(Object another)
equals in class Objectpublic Type getCompatibleType(Type other)
If the type passed in represents a primitive type, but this type is not, the type returned is an object (or a subclass of), but never a primitive type. Compatible primitive types are returned when both this and the parameter type were already primitive types.
Input types which are arrays are also supported by this method.
Returns null if the given type isn't compatible with this one.
public static Type getIterationType(GenericType type)
OBJECT_TYPE is returned.
type - The generic type
public static Type getKeyType(GenericType type)
OBJECT_TYPE is returned.
type - The generic type
public static Type getValueType(GenericType type)
OBJECT_TYPE
is returned.
type - The generic type
protected static Type getTypeArgument(GenericType type,
int index)
OBJECT_TYPE is returned.
type - The generic typeindex - The index of the type argument
public static Type preserveType(Type currentType,
Type newType)
public static Class<?> findCommonBaseClass(Class<?> a,
Class<?> b)
public int convertableFrom(Type other)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||