Class GenericMetadataSupport.TypeVarBoundedType

java.lang.Object
org.mockito.internal.util.reflection.GenericMetadataSupport.TypeVarBoundedType
All Implemented Interfaces:
Type, GenericMetadataSupport.BoundedType
Enclosing class:
GenericMetadataSupport

public static class GenericMetadataSupport.TypeVarBoundedType extends Object implements GenericMetadataSupport.BoundedType
Type representing bounds of a type variable, allows to keep all bounds information.

It uses the first bound in the array, as this array is never null and always contains at least one element (Object is always here if no bounds are declared).

If upper bounds are declared with SomeClass and additional interfaces, then firstBound will be SomeClass and interfacesBound will be an array of the additional interfaces.

i.e. SomeClass.


     interface UpperBoundedTypeWithClass<E extends Comparable & Cloneable> {
         E get();
     }
     // will return Comparable type
 

See Also:
  • Field Details

  • Constructor Details

    • TypeVarBoundedType

      public TypeVarBoundedType(TypeVariable<?> typeVariable)
  • Method Details

    • firstBound

      public Type firstBound()
      Specified by:
      firstBound in interface GenericMetadataSupport.BoundedType
      Returns:
      either a class or an interface (parameterized or not), if no bounds declared Object is returned.
    • interfaceBounds

      public Type[] interfaceBounds()
      On a Type Variable (typeVar extends C_0 & I_1 & I_2 & etc), will return an array containing I_1 and I_2.
      Specified by:
      interfaceBounds in interface GenericMetadataSupport.BoundedType
      Returns:
      other bounds for this type, these bounds can only be only interfaces as the JLS says, empty array if no other bound declared.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • typeVariable

      public TypeVariable<?> typeVariable()