Class JavaType

    • Method Detail

      • isTagged

        public boolean isTagged​(int tag)
      • 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.
      • 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.
      • erasure

        public JavaType erasure()
        JLS8 4.6
        Specified by:
        erasure in interface Type
        Returns:
        erased type.
      • 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
      • 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.
      • isPrimitiveWrapper

        public boolean isPrimitiveWrapper()
      • 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.
      • isParameterized

        public boolean isParameterized()
      • 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.
      • 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.