Class Symbols.UnknownType
java.lang.Object
org.sonar.java.model.Symbols.UnknownType
- All Implemented Interfaces:
Type
- Enclosing class:
Symbols
-
Nested Class Summary
Nested classes/interfaces inherited from interface Type
Type.ArrayType, Type.Primitives -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the declaring type of this typeerasure()Erasure of this type.Fully qualified name of the type.Type[]This method returns more than one type whenType.isIntersectionType()is true.booleanCheck 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.booleanCheck if this type is an intersection type.booleanReturns whether this type is the null typebooleanCheck if this type is a primitive numerical type.booleanCheck if the current type is a parameterized type or not.booleanCheck if this type is a primitive.booleanisPrimitive(Type.Primitives primitive) Check if this type is the given primitive.booleanCheck if this type is a primitive wrapper.booleanCheck if this type is a raw typebooleanisSubtypeOf(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.booleanReturns whether this type represents a type variablebooleanCheck if this type has been resolved.booleanisVoid()Check if type is Void type.name()simple name of the type.Returns the type of the primitiveReturns the type of the primitive wrappersymbol()Symbol of this type.The arguments of a parameterized type, as a parameterization of a generic type.
-
Constructor Details
-
UnknownType
public UnknownType()
-
-
Method Details
-
is
Description copied from interface:TypeCheck 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"); -
isSubtypeOf
Description copied from interface:TypeCheck 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");- Specified by:
isSubtypeOfin interfaceType- 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
Description copied from interface:TypeCheck whether a type is a subtype of another.This method will consider implemented interfaces as well as superclasses.
Type type, myOtherType; type.isSubtypeOf(myOtherType);
- Specified by:
isSubtypeOfin interfaceType- 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
-
isClass
-
isVoid
-
isPrimitive
public boolean isPrimitive()Description copied from interface:TypeCheck if this type is a primitive.- Specified by:
isPrimitivein interfaceType- Returns:
- true if this is a primitive type.
-
isPrimitive
Description copied from interface:TypeCheck if this type is the given primitive.Type type; type.isPrimitive(Primitives.INT);
- Specified by:
isPrimitivein interfaceType- Parameters:
primitive- primitive type to be checked with.- Returns:
- true if this is the primitive type
-
isPrimitiveWrapper
public boolean isPrimitiveWrapper()Description copied from interface:TypeCheck if this type is a primitive wrapper.Type type; type.isPrimitiveWrapper();
- Specified by:
isPrimitiveWrapperin interfaceType- Returns:
- true if this is a primitive wrapper
-
primitiveWrapperType
Description copied from interface:TypeReturns the type of the primitive wrapperType type; Type primitiveWrapperType = type.primitiveWrapperType();
- Specified by:
primitiveWrapperTypein interfaceType- Returns:
- the type of the primitive wrapper, as Type
-
primitiveType
Description copied from interface:TypeReturns the type of the primitiveType type; Type primitiveType = type.primitiveType();
- Specified by:
primitiveTypein interfaceType- Returns:
- the type of the primitive, as Type
-
isNullType
public boolean isNullType()Description copied from interface:TypeReturns whether this type is the null typeType type; type.isNullType();
- Specified by:
isNullTypein interfaceType- Returns:
- true if it is a null type
-
isTypeVar
-
isRawType
-
declaringType
Description copied from interface:TypeReturns the declaring type of this typeType type; Type declaringType = type.declaringType();
- Specified by:
declaringTypein interfaceType- Returns:
- the declaring type of this, as Type
-
isUnknown
public boolean isUnknown()Description copied from interface:TypeCheck 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. -
isNumerical
public boolean isNumerical()Description copied from interface:TypeCheck if this type is a primitive numerical type.- Specified by:
isNumericalin interfaceType- Returns:
- true if type is byte, char, short, int, long, float or double.
-
fullyQualifiedName
Description copied from interface:TypeFully qualified name of the type.- Specified by:
fullyQualifiedNamein interfaceType- Returns:
- complete name of type.
-
name
-
symbol
Description copied from interface:TypeSymbol of this type. -
erasure
-
isParameterized
public boolean isParameterized()Description copied from interface:TypeCheck if the current type is a parameterized type or not.- Specified by:
isParameterizedin interfaceType- Returns:
- true in case of Generic and Parameterized types
-
typeArguments
Description copied from interface:TypeThe arguments of a parameterized type, as a parameterization of a generic type.- Specified by:
typeArgumentsin interfaceType- Returns:
- the ordered list of type arguments. Returns an empty lists for non-parameterized types.
-
isIntersectionType
public boolean isIntersectionType()Description copied from interface:TypeCheck if this type is an intersection type. For example, return true for the type of 'x' in the following code:var x = (AutoCloseable invalid input: '&' Cloneable) obj;- Specified by:
isIntersectionTypein interfaceType
-
getIntersectionTypes
Description copied from interface:TypeThis method returns more than one type whenType.isIntersectionType()is true. For example, it returns["java.lang.AutoCloseable", "java.lang.Cloneable"]for the type of 'x' in the following code:var x = (AutoCloseable invalid input: '&' Cloneable) obj;- Specified by:
getIntersectionTypesin interfaceType
-