public class JavaType extends Object implements Type
| Modifier and Type | Class and Description |
|---|---|
static class |
JavaType.ArrayJavaType |
static class |
JavaType.ClassJavaType |
static class |
JavaType.MethodJavaType |
static class |
JavaType.ParametrizedTypeJavaType |
static class |
JavaType.TypeVariableJavaType |
static class |
JavaType.UnknownType |
static class |
JavaType.WildCardType |
Type.ArrayType, Type.Primitives| Modifier and Type | Field and Description |
|---|---|
static int |
ARRAY |
static int |
BOOLEAN |
static int |
BOT |
static int |
BYTE |
static int |
CHAR |
static int |
CLASS |
static int |
DOUBLE |
static int |
FLOAT |
static int |
INT |
static int |
LONG |
static int |
METHOD |
static int |
SHORT |
static int |
TYPEVAR |
static int |
UNKNOWN |
static int |
VOID |
static int |
WILDCARD |
| Constructor and Description |
|---|
JavaType(int tag,
JavaSymbol.TypeJavaSymbol symbol) |
| Modifier and Type | Method and Description |
|---|---|
JavaType |
erasure()
JLS8 4.6
|
String |
fullyQualifiedName()
Fully qualified name of the type.
|
JavaSymbol.TypeJavaSymbol |
getSymbol() |
boolean |
is(String fullyQualifiedName)
Check whether a type is the one designed by the fully qualified name.
|
boolean |
isArray()
Check if this type is an array.
|
boolean |
isClass()
Check if this type is a class, an enum, an interface or an annotation.
|
boolean |
isNumerical()
Check if this type is a primitive numerical type.
|
boolean |
isPrimitive()
Check if this type is a primitive.
|
boolean |
isPrimitive(Type.Primitives primitive)
Check if this type is the given primitive.
|
boolean |
isPrimitiveWrapper() |
boolean |
isSubtypeOf(String fullyQualifiedName)
Check whether a type is a subtype of the one designed by the fully qualified name.
|
boolean |
isSubtypeOf(Type superType)
Check whether a type is a subtype of another.
|
boolean |
isTagged(int tag) |
boolean |
isUnknown()
Check if this type has been resolved.
|
boolean |
isVoid()
Check if type is Void type.
|
String |
name()
simple name of the type.
|
JavaType |
primitiveType() |
JavaType |
primitiveWrapperType() |
Symbol.TypeSymbol |
symbol()
Symbol of this type.
|
String |
toString() |
public static final int BYTE
public static final int CHAR
public static final int SHORT
public static final int INT
public static final int LONG
public static final int FLOAT
public static final int DOUBLE
public static final int BOOLEAN
public static final int VOID
public static final int CLASS
public static final int ARRAY
public static final int METHOD
public static final int BOT
public static final int UNKNOWN
public static final int TYPEVAR
public static final int WILDCARD
public JavaType(int tag,
JavaSymbol.TypeJavaSymbol symbol)
public boolean isTagged(int tag)
public boolean isNumerical()
TypeisNumerical in interface Typepublic JavaSymbol.TypeJavaSymbol getSymbol()
public boolean is(String fullyQualifiedName)
Type
Type type;
type.is("int");
type.is("int[]");
type.is("java.lang.String[]");
type.is("java.lang.Object");
public boolean isSubtypeOf(String fullyQualifiedName)
Type
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");
isSubtypeOf in interface TypefullyQualifiedName - fully qualified name to check in the type hierarchy. Use "[]" for arrays.public boolean isSubtypeOf(Type superType)
Type
This method will consider implemented interfaces as well as superclasses.
Type type, myOtherType;
type.isSubtypeOf(myOtherType);
isSubtypeOf in interface TypesuperType - instance of a potential superType.public boolean isPrimitive()
TypeisPrimitive in interface Typepublic boolean isPrimitive(Type.Primitives primitive)
Type
Type type;
type.isPrimitive(Primitives.INT);
isPrimitive in interface Typeprimitive - primitive type to be checked with.public boolean isUnknown()
Typepublic boolean isPrimitiveWrapper()
public boolean isArray()
Typepublic boolean isClass()
Typepublic boolean isVoid()
Typepublic String fullyQualifiedName()
TypefullyQualifiedName in interface Typepublic Symbol.TypeSymbol symbol()
TypeCopyright © 2012–2016 SonarSource. All rights reserved.