Class TypeHolder<T>

  • Type Parameters:
    T - Type to be inferred.

    public abstract class TypeHolder<T>
    extends java.lang.Object
    An abstract class to infer ParameterizedTypes for a child class. This type can be retrieved from type().

    In order to use this, one has to create an anonymous sub-class, like:

      TypeHolder<Set<String>> holder = new TypeHolder<Set<String>>() { };
     
    This implementation is based on the samples provided in this article..
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected TypeHolder()
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.reflect.Type type()
      Returns the inferred generic type for this TypeHolder.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TypeHolder

        protected TypeHolder()
        Creates a new instance.
    • Method Detail

      • type

        public final java.lang.reflect.Type type()
        Returns the inferred generic type for this TypeHolder.
        Returns:
        Inferred generic type for this TypeHolder.