Class GenericMetadataSupport.TypeVarBoundedType

  • All Implemented Interfaces:
    java.lang.reflect.Type, GenericMetadataSupport.BoundedType
    Enclosing class:
    GenericMetadataSupport

    public static class GenericMetadataSupport.TypeVarBoundedType
    extends java.lang.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 & Cloneable> {
             E get();
         }
         // will return Comparable type
     

    See Also:
    https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.4
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.reflect.TypeVariable<?> typeVariable  
    • Constructor Summary

      Constructors 
      Constructor Description
      TypeVarBoundedType​(java.lang.reflect.TypeVariable<?> typeVariable)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.lang.reflect.Type firstBound()  
      int hashCode()  
      java.lang.reflect.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.
      java.lang.String toString()  
      java.lang.reflect.TypeVariable<?> typeVariable()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.reflect.Type

        getTypeName
    • Field Detail

      • typeVariable

        private final java.lang.reflect.TypeVariable<?> typeVariable
    • Constructor Detail

      • TypeVarBoundedType

        public TypeVarBoundedType​(java.lang.reflect.TypeVariable<?> typeVariable)
    • Method Detail

      • firstBound

        public java.lang.reflect.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 java.lang.reflect.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​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

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

        public java.lang.reflect.TypeVariable<?> typeVariable()