ca.grimoire.formtree.receiver.constructor
Class ArrayReceiver<T>

java.lang.Object
  extended by ca.grimoire.formtree.receiver.constructor.CollectionReceiver<T,T[]>
      extended by ca.grimoire.formtree.receiver.constructor.ArrayReceiver<T>
Type Parameters:
T - the class of the array elements.
All Implemented Interfaces:
FormElementReceiver, FormReceiver<T[]>

public class ArrayReceiver<T>
extends CollectionReceiver<T,T[]>

Receives form elements into an array of some constructible class. The array may be dense (if handled via the CollectionReceiver.values(Iterable) method) or sparse (if handled via the CollectionReceiver.key(String) method).

See Also:
ConstructorReceiver

Field Summary
 
Fields inherited from class ca.grimoire.formtree.receiver.constructor.CollectionReceiver
elementClass
 
Constructor Summary
ArrayReceiver(java.lang.Class<T> elementClass)
          Creates an ArrayReceiver that will create arrays of elementClass.
 
Method Summary
static java.lang.Class<?> acceptableArrayClass(java.lang.Class<?> type)
          Determines if a Class representing an array type can be processed using this receiver.
static
<T> ArrayReceiver<T>
create(java.lang.Class<T> elementClass)
          A type-inferring alternative to ArrayReceiver(Class).
protected  T[] createCollection(java.util.List<T> elements)
          Builds an array out of the passed element list.
 
Methods inherited from class ca.grimoire.formtree.receiver.constructor.CollectionReceiver
acceptableElementClass, acceptableElementClass, finished, index, key, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayReceiver

public ArrayReceiver(java.lang.Class<T> elementClass)
Creates an ArrayReceiver that will create arrays of elementClass.

Parameters:
elementClass - the Class of <T>
Method Detail

acceptableArrayClass

public static java.lang.Class<?> acceptableArrayClass(java.lang.Class<?> type)
Determines if a Class representing an array type can be processed using this receiver. The elements of the array must be constructible (either via ConstructorReceiver or via StringConstructorReceiver).

Parameters:
type - the class to test.
Returns:
the class of the array elements being held, or null if type cannot be used to hold form data.

create

public static <T> ArrayReceiver<T> create(java.lang.Class<T> elementClass)
A type-inferring alternative to ArrayReceiver(Class).

Type Parameters:
T - the class of the array elements.
Parameters:
elementClass - the Class of <T>
Returns:
a new ArrayReceiver.

createCollection

protected T[] createCollection(java.util.List<T> elements)
Builds an array out of the passed element list. The array will have component type <T>.

Specified by:
createCollection in class CollectionReceiver<T,T[]>
Parameters:
elements - the collection contents.
Returns:
the corresponding collection.
See Also:
CollectionReceiver.createCollection(java.util.List)


Copyright © 2011 Grimoire Alchymia. All Rights Reserved.