Package org.sonar.java.resolve
Class ArrayJavaType
- java.lang.Object
-
- org.sonar.java.resolve.JavaType
-
- org.sonar.java.resolve.ArrayJavaType
-
- All Implemented Interfaces:
Type,Type.ArrayType
public class ArrayJavaType extends JavaType implements Type.ArrayType
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.sonar.plugins.java.api.semantic.Type
Type.ArrayType, Type.Primitives
-
-
Constructor Summary
Constructors Constructor Description ArrayJavaType(JavaType elementType, JavaSymbol.TypeJavaSymbol arrayClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JavaTypeelementType()Type of elements in this array.booleanequals(Object obj)JavaTypeerasure()JLS8 4.6inthashCode()booleanis(String fullyQualifiedName)Check whether a type is the one designed by the fully qualified name.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.StringtoString()-
Methods inherited from class org.sonar.java.resolve.JavaType
directSuperTypes, fullyQualifiedName, getSuperType, getSymbol, isArray, isClass, isNumerical, isParameterized, isPrimitive, isPrimitive, isPrimitiveWrapper, isTagged, isUnknown, isVoid, name, primitiveType, primitiveWrapperType, symbol
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.sonar.plugins.java.api.semantic.Type
fullyQualifiedName, isArray, isClass, isNumerical, isPrimitive, isPrimitive, isUnknown, isVoid, name, symbol
-
-
-
-
Constructor Detail
-
ArrayJavaType
public ArrayJavaType(JavaType elementType, JavaSymbol.TypeJavaSymbol arrayClass)
- Parameters:
arrayClass-Symbols.arrayClass
-
-
Method Detail
-
is
public boolean is(String fullyQualifiedName)
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
public boolean isSubtypeOf(String fullyQualifiedName)
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- Overrides:
isSubtypeOfin classJavaType- 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
public boolean isSubtypeOf(Type superType)
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- Overrides:
isSubtypeOfin classJavaType- 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.
-
elementType
public JavaType elementType()
Description copied from interface:Type.ArrayTypeType of elements in this array.- Specified by:
elementTypein interfaceType.ArrayType- Returns:
- type of an element.
-
-