Class Lister<T>


  • public abstract class Lister<T>
    extends java.lang.Object
    Abstracts away the process of creating a collection (array, List, etc) of items.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.Class[] CONCRETE_TYPES  
      java.lang.reflect.Type itemGenericType  
      java.lang.Class itemType
      Type of the individual item
      protected java.util.Collection r  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Lister​(java.lang.Class itemType, java.lang.reflect.Type itemGenericType)  
      protected Lister​(java.lang.Class itemType, java.lang.reflect.Type itemGenericType, java.util.Collection r)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.Object o)  
      static <T> Lister<T> create​(java.lang.Class<T> c, java.lang.reflect.Type t)
      Creates a Lister instance that produces the given type.
      static Lister create​(java.lang.reflect.Type t)
      Creates a Lister instance that produces the given type.
      abstract T toCollection()  
      private static java.lang.IllegalAccessError toError​(java.lang.IllegalAccessException e)  
      private static java.lang.InstantiationError toError​(java.lang.InstantiationException e)  
      • Methods inherited from class java.lang.Object

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

      • itemType

        public final java.lang.Class itemType
        Type of the individual item
      • itemGenericType

        public final java.lang.reflect.Type itemGenericType
      • r

        protected final java.util.Collection r
      • CONCRETE_TYPES

        private static final java.lang.Class[] CONCRETE_TYPES
    • Constructor Detail

      • Lister

        protected Lister​(java.lang.Class itemType,
                         java.lang.reflect.Type itemGenericType)
      • Lister

        protected Lister​(java.lang.Class itemType,
                         java.lang.reflect.Type itemGenericType,
                         java.util.Collection r)
    • Method Detail

      • add

        public void add​(java.lang.Object o)
      • toCollection

        public abstract T toCollection()
      • create

        public static Lister create​(java.lang.reflect.Type t)
        Creates a Lister instance that produces the given type.
      • create

        public static <T> Lister<T> create​(java.lang.Class<T> c,
                                           java.lang.reflect.Type t)
        Creates a Lister instance that produces the given type.
        Parameters:
        c - The erasure version of 't'. This is taken as a parameter as a performance optimizaiton.
        Returns:
        null if the given type doesn't look like a collection.
        Throws:
        java.lang.IllegalArgumentException - if the given type does look like a collection yet this implementation is not capable of how to handle it.
      • toError

        private static java.lang.IllegalAccessError toError​(java.lang.IllegalAccessException e)
      • toError

        private static java.lang.InstantiationError toError​(java.lang.InstantiationException e)