Class Type

  • All Implemented Interfaces:
    Excerpt
    Direct Known Subclasses:
    Type.TypeImpl, TypeClass

    public abstract class Type
    extends ValueType
    implements Excerpt
    Representation of a parameterized class or interface type.

    Similar to DeclaredType, with a code-generation and test-friendly focus.

    • Constructor Detail

      • Type

        public Type()
    • Method Detail

      • from

        public static Type from​(javax.lang.model.type.DeclaredType declaredType)
      • from

        public static Type from​(java.lang.Class<?> cls)
      • getQualifiedName

        public abstract QualifiedName getQualifiedName()
        Returns the qualified name of the type class.
      • getTypeParameters

        protected abstract java.util.List<?> getTypeParameters()
      • getSimpleName

        public java.lang.String getSimpleName()
        Returns the simple name of the type class.
      • isParameterized

        public boolean isParameterized()
        Returns true if the type class is generic.
      • constructor

        public Excerpt constructor()
        Returns a source excerpt suitable for constructing an instance of this type, including "new" keyword but excluding brackets.
      • javadocLink

        public Type.JavadocLink javadocLink()
        Returns a source excerpt of a JavaDoc link to this type.
      • javadocNoArgMethodLink

        public Type.JavadocLink javadocNoArgMethodLink​(java.lang.String memberName)
        Returns a source excerpt of a JavaDoc link to a no-args method on this type.
      • javadocMethodLink

        public Type.JavadocLink javadocMethodLink​(java.lang.String memberName,
                                                  Type... types)
        Returns a source excerpt of a JavaDoc link to a method on this type.
      • typeParameters

        public Excerpt typeParameters()
        Returns a source excerpt of the type parameters of this type, including angle brackets. Always an empty string if the type class is not generic.

        e.g. <N, C>

      • diamondOperator

        public Excerpt diamondOperator()
        Returns a source excerpt equivalent to the diamond operator for this type.

        Always an empty string if the type class is not generic.

      • withWildcards

        public Type withWildcards()
        Returns a new type of the same class, parameterized with wildcards ("?").

        If the type class is not generic, the returned object will be equal to this one.