Class Type

java.lang.Object
org.inferred.freebuilder.processor.source.ValueType
org.inferred.freebuilder.processor.source.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 Details

    • Type

      public Type()
  • Method Details

    • from

      public static Type from(DeclaredType declaredType)
    • from

      public static Type from(Class<?> cls)
    • getQualifiedName

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

      protected abstract List<?> getTypeParameters()
    • getSimpleName

      public 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(String memberName)
      Returns a source excerpt of a JavaDoc link to a no-args method on this type.
    • javadocMethodLink

      public Type.JavadocLink javadocMethodLink(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.

    • addTo

      public void addTo(SourceBuilder source)
      Specified by:
      addTo in interface Excerpt