Interface Type
-
- All Known Subinterfaces:
Type.ArrayType
public interface TypeInterface to access resolved type of an expression or a Type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceType.ArrayTypeType for arrays.static classType.PrimitivesPrimitive java types.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Typeerasure()Erasure of this type.StringfullyQualifiedName()Fully qualified name of the type.booleanis(String fullyQualifiedName)Check whether a type is the one designed by the fully qualified name.booleanisArray()Check if this type is an array.booleanisClass()Check if this type is a class, an enum, an interface or an annotation.booleanisNumerical()Check if this type is a primitive numerical type.booleanisPrimitive()Check if this type is a primitive.booleanisPrimitive(Type.Primitives primitive)Check if this type is the given primitive.booleanisSubtypeOf(String fullyQualifiedName)Check whether a type is a subtype of the one designed by the fully qualified name.booleanisSubtypeOf(Type superType)Check whether a type is a subtype of another.booleanisUnknown()Check if this type has been resolved.booleanisVoid()Check if type is Void type.Stringname()simple name of the type.Symbol.TypeSymbolsymbol()Symbol of this type.
-
-
-
Method Detail
-
is
boolean is(String fullyQualifiedName)
Check whether a type is the one designed by the fully qualified name.Type type; type.is("int"); type.is("int[]"); type.is("java.lang.String[]"); type.is("java.lang.Object");- Parameters:
fullyQualifiedName- fully qualified name to check. Use "[]" for arrays and the simple name for primitive type ("int", "byte"...).- Returns:
- true if the type is the one looked for. false otherwise.
-
isSubtypeOf
boolean isSubtypeOf(String fullyQualifiedName)
Check whether a type is a subtype of the one designed by the fully qualified name.This method will consider implemented interfaces as well as superclasses.
Type type; type.isSubtypeOf("Object[]"); type.isSubtypeOf("org.mypackage.MyClass"); type.isSubtypeOf("org.mypackage.MyInterface"); type.isSubtypeOf("java.lang.Object");- Parameters:
fullyQualifiedName- fully qualified name to check in the type hierarchy. Use "[]" for arrays.- Returns:
- true if the type is the one passed in parameter or have this type in its hierarchy. false otherwise.
-
isSubtypeOf
boolean isSubtypeOf(Type superType)
Check whether a type is a subtype of another.This method will consider implemented interfaces as well as superclasses.
Type type, myOtherType; type.isSubtypeOf(myOtherType);
- Parameters:
superType- instance of a potential superType.- Returns:
- true if types are equivalent or if the one passed in parameter is in the hierarchy. false otherwise.
-
isArray
boolean isArray()
Check if this type is an array.- Returns:
- true if this is an array.
-
isClass
boolean isClass()
Check if this type is a class, an enum, an interface or an annotation.- Returns:
- true if this is a class, enum, interface or annotation.
-
isVoid
boolean isVoid()
Check if type is Void type. This is used to check type of method invocation expressions.- Returns:
- true if the type is void.
-
isPrimitive
boolean isPrimitive()
Check if this type is a primitive.- Returns:
- true if this is a primitive type.
-
isPrimitive
boolean isPrimitive(Type.Primitives primitive)
Check if this type is the given primitive.Type type; type.isPrimitive(Primitives.INT);
- Parameters:
primitive- primitive type to be checked with.- Returns:
- true if this is the primitive type
-
isUnknown
boolean isUnknown()
Check if this type has been resolved. Type can be unknown in incomplete part of Semantic Analysis or when bytecode for a type is not provided and a method cannot be resolved.- Returns:
- true if type has not been resolved by semantic analysis.
-
isNumerical
boolean isNumerical()
Check if this type is a primitive numerical type.- Returns:
- true if type is byte, char, short, int, long, float or double.
-
fullyQualifiedName
String fullyQualifiedName()
Fully qualified name of the type.- Returns:
- complete name of type.
-
name
String name()
simple name of the type.- Returns:
- simple name of type.
-
symbol
Symbol.TypeSymbol symbol()
Symbol of this type.- Returns:
- the symbol declaring this type.
-
erasure
Type erasure()
Erasure of this type.- Returns:
- erased type.
-
-