Class TypeVariable.Builder

Enclosing class:
TypeVariable

public static final class TypeVariable.Builder extends Type.Builder<TypeVariable.Builder>
Convenient builder for TypeVariable. If no bound is added, the built type variable will have a single bound of java.lang.Object.
Since:
3.1.0
  • Field Details

    • identifier

      private final String identifier
    • bounds

      private final List<Type> bounds
    • hasImplicitObjectBound

      private boolean hasImplicitObjectBound
  • Constructor Details

    • Builder

      Builder(String identifier)
  • Method Details

    • implicitObjectBound

      public TypeVariable.Builder implicitObjectBound()
      Marks the built type variable as having an implicit (not declared) bound of Object. It follows that all bounds added via addBound(Type), if any, are interface types. The erasure of the type variable is not necessarily Object though; if any interface bounds are added via addBound(Type), the first such interface type is the erasure.
      Returns:
      this builder
      Since:
      3.3.2
    • addBound

      public TypeVariable.Builder addBound(Type bound)
      Adds a bound. The first bound may be a class type or a type variable. If the first bound is a class type (or if the type variable has an implicitObjectBound()), the subsequent bounds must be interface types. If the first bound is a type variable, there may be no subsequent bounds.
      Parameters:
      bound - the bound, must not be null
      Returns:
      this builder
    • addBound

      public TypeVariable.Builder addBound(Class<?> clazz)
      Adds a bound. The first bound may be a class type or a type variable. If the first bound is a class type (or if the type variable has an implicitObjectBound()), the subsequent bounds must be interface types. If the first bound is a type variable, there may be no subsequent bounds.
      Parameters:
      clazz - the class whose type is added as a bound, must not be null
      Returns:
      this builder
    • build

      public TypeVariable build()
      Returns the built type variable.
      Returns:
      the built type variable