Class ArrayType


  • public final class ArrayType
    extends Type
    Represents a Java array type declaration.
    Since:
    2.0
    Author:
    Jason T. Greene
    • Method Detail

      • create

        public static ArrayType create​(Type component,
                                       int dimensions)
        Create a new mock array type instance with the specified component and dimensions.
        Parameters:
        component - the array component
        dimensions - the number of dimensions of this array
        Returns:
        the new mock array type instance
        Since:
        2.1
      • component

        public Type component()
        Returns the component type of the array. As an example, String[] has a component type of String
        Returns:
        the component type
      • name

        public DotName name()
        Description copied from class: Type
        Returns the raw name of this type. Primitives and void are returned as the Java reserved word (void, boolean, byte, short, char, int, long, float, double). Arrays are returned using the Java reflection array syntax (e.g. "[[[Ljava.lang.String;") Classes are returned as a normal DotName.

        Generic values are returned as the underlying raw value. For example, a wildcard such as ? extends Number, has a raw type of Number

        Overrides:
        name in class Type
        Returns:
        the name of this type
      • toString

        public String toString()
        Description copied from class: Type
        Returns a string representation for this type. It is similar, yet not equivalent to a Java source code representation.
        Overrides:
        toString in class Type
        Returns:
        the string representation.
      • dimensions

        public int dimensions()
        The number of dimensions this array type has. For example, String[][], would return a value of 2.
        Returns:
        the number of dimensions of this array type
      • kind

        public Type.Kind kind()
        Description copied from class: Type
        Returns the kind of Type this is.
        Specified by:
        kind in class Type
        Returns:
        the kind
      • equals

        public boolean equals​(Object o)
        Description copied from class: Type
        Compares this Type with another type, and returns true if they are equivalent. A type is equivalent to another type if it is the same kind, and all of its fields are equal. This includes annotations, which must be equal as well.
        Overrides:
        equals in class Type
        Parameters:
        o - the type to compare to
        Returns:
        true if equal
        See Also:
        Object.equals(Object)
      • hashCode

        public int hashCode()
        Description copied from class: Type
        Computes a hash code representing this type.
        Overrides:
        hashCode in class Type
        Returns:
        the hash code