org.jvnet.tiger_types
Class Lister<T>

java.lang.Object
  extended by org.jvnet.tiger_types.Lister<T>

public abstract class Lister<T>
extends Object

Abstracts away the process of creating a collection (array, List, etc) of items.

Author:
Kohsuke Kawaguchi

Field Summary
 Type itemGenericType
           
 Class itemType
          Type of the individual item
protected  Collection r
           
 
Constructor Summary
protected Lister(Class itemType, Type itemGenericType)
           
protected Lister(Class itemType, Type itemGenericType, Collection r)
           
 
Method Summary
 void add(Object o)
           
static
<T> Lister<T>
create(Class<T> c, Type t)
          Creates a Lister instance that produces the given type.
static Lister create(Type t)
          Creates a Lister instance that produces the given type.
abstract  T toCollection()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itemType

public final Class itemType
Type of the individual item


itemGenericType

public final Type itemGenericType

r

protected final Collection r
Constructor Detail

Lister

protected Lister(Class itemType,
                 Type itemGenericType)

Lister

protected Lister(Class itemType,
                 Type itemGenericType,
                 Collection r)
Method Detail

add

public void add(Object o)

toCollection

public abstract T toCollection()

create

public static Lister create(Type t)
Creates a Lister instance that produces the given type.


create

public static <T> Lister<T> create(Class<T> c,
                                   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:
IllegalArgumentException - if the given type does look like a collection yet this implementation is not capable of how to handle it.


Copyright © 2013. All Rights Reserved.