Class Symbols.UnknownType

java.lang.Object
org.sonar.java.model.Symbols.UnknownType
All Implemented Interfaces:
Type
Enclosing class:
Symbols

public static final class Symbols.UnknownType extends Object implements Type
  • Constructor Details

    • UnknownType

      public UnknownType()
  • Method Details

    • is

      public boolean is(String fullyQualifiedName)
      Description copied from interface: Type
      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");
      
      Specified by:
      is in interface Type
      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

      public boolean isSubtypeOf(String fullyQualifiedName)
      Description copied from interface: Type
      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");
      
      Specified by:
      isSubtypeOf in interface Type
      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: Type
      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);
      
      Specified by:
      isSubtypeOf in interface Type
      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

      public boolean isArray()
      Description copied from interface: Type
      Check if this type is an array.
      Specified by:
      isArray in interface Type
      Returns:
      true if this is an array.
    • isClass

      public boolean isClass()
      Description copied from interface: Type
      Check if this type is a class, an enum, an interface or an annotation.
      Specified by:
      isClass in interface Type
      Returns:
      true if this is a class, enum, interface or annotation.
    • isVoid

      public boolean isVoid()
      Description copied from interface: Type
      Check if type is Void type. This is used to check type of method invocation expressions.
      Specified by:
      isVoid in interface Type
      Returns:
      true if the type is void.
    • isPrimitive

      public boolean isPrimitive()
      Description copied from interface: Type
      Check if this type is a primitive.
      Specified by:
      isPrimitive in interface Type
      Returns:
      true if this is a primitive type.
    • isPrimitive

      public boolean isPrimitive(Type.Primitives primitive)
      Description copied from interface: Type
      Check if this type is the given primitive.
         Type type;
         type.isPrimitive(Primitives.INT);
      
      Specified by:
      isPrimitive in interface Type
      Parameters:
      primitive - primitive type to be checked with.
      Returns:
      true if this is the primitive type
    • isPrimitiveWrapper

      public boolean isPrimitiveWrapper()
      Description copied from interface: Type
      Check if this type is a primitive wrapper.
         Type type;
         type.isPrimitiveWrapper();
      
      Specified by:
      isPrimitiveWrapper in interface Type
      Returns:
      true if this is a primitive wrapper
    • primitiveWrapperType

      @Nullable public Type primitiveWrapperType()
      Description copied from interface: Type
      Returns the type of the primitive wrapper
         Type type;
         Type primitiveWrapperType = type.primitiveWrapperType();
      
      Specified by:
      primitiveWrapperType in interface Type
      Returns:
      the type of the primitive wrapper, as Type
    • primitiveType

      @Nullable public Type primitiveType()
      Description copied from interface: Type
      Returns the type of the primitive
         Type type;
         Type primitiveType = type.primitiveType();
      
      Specified by:
      primitiveType in interface Type
      Returns:
      the type of the primitive, as Type
    • isNullType

      public boolean isNullType()
      Description copied from interface: Type
      Returns whether this type is the null type
         Type type;
         type.isNullType();
      
      Specified by:
      isNullType in interface Type
      Returns:
      true if it is a null type
    • isTypeVar

      public boolean isTypeVar()
      Description copied from interface: Type
      Returns whether this type represents a type variable
         Type type;
         type.isTypeVar();
      
      Specified by:
      isTypeVar in interface Type
      Returns:
      true if this is a type variable
    • isRawType

      public boolean isRawType()
      Description copied from interface: Type
      Check if this type is a raw type
         Type type;
         type.isRawType();
      
      Specified by:
      isRawType in interface Type
      Returns:
      true if it is a raw type
    • declaringType

      public Type declaringType()
      Description copied from interface: Type
      Returns the declaring type of this type
         Type type;
         Type declaringType = type.declaringType();
      
      Specified by:
      declaringType in interface Type
      Returns:
      the declaring type of this, as Type
    • isUnknown

      public boolean isUnknown()
      Description copied from interface: Type
      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.
      Specified by:
      isUnknown in interface Type
      Returns:
      true if type has not been resolved by semantic analysis.
    • isNumerical

      public boolean isNumerical()
      Description copied from interface: Type
      Check if this type is a primitive numerical type.
      Specified by:
      isNumerical in interface Type
      Returns:
      true if type is byte, char, short, int, long, float or double.
    • fullyQualifiedName

      public String fullyQualifiedName()
      Description copied from interface: Type
      Fully qualified name of the type.
      Specified by:
      fullyQualifiedName in interface Type
      Returns:
      complete name of type.
    • name

      public String name()
      Description copied from interface: Type
      simple name of the type.
      Specified by:
      name in interface Type
      Returns:
      simple name of type.
    • symbol

      public Symbol.TypeSymbol symbol()
      Description copied from interface: Type
      Symbol of this type.
      Specified by:
      symbol in interface Type
      Returns:
      the symbol declaring this type.
    • erasure

      public Type erasure()
      Description copied from interface: Type
      Erasure of this type.
      Specified by:
      erasure in interface Type
      Returns:
      erased type.
    • isParameterized

      public boolean isParameterized()
      Description copied from interface: Type
      Check if the current type is a parameterized type or not.
      Specified by:
      isParameterized in interface Type
      Returns:
      true in case of Generic and Parameterized types
    • typeArguments

      public List<Type> typeArguments()
      Description copied from interface: Type
      The arguments of a parameterized type, as a parameterization of a generic type.
      Specified by:
      typeArguments in interface Type
      Returns:
      the ordered list of type arguments. Returns an empty lists for non-parameterized types.
    • isIntersectionType

      public boolean isIntersectionType()
      Description copied from interface: Type
      Check 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:
      isIntersectionType in interface Type
    • getIntersectionTypes

      public Type[] getIntersectionTypes()
      Description copied from interface: Type
      This method returns more than one type when Type.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:
      getIntersectionTypes in interface Type