|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.grimoire.formtree.receiver.constructor.CollectionReceiver<E,T>
E - the type of the elements of the resulting collection.T - the type of the resulting collection. This doesn't have to be a
subclass of Collection - other collection types, such as
arrays, are possible.public abstract class CollectionReceiver<E,T>
Supporting behaviour allowing for form receivers that produce collections. Manages collating and populating the individual elements of the collection. Subclasses are responsible for turning the elements into a finished collection.
ArrayReceiver,
ListReceiver,
SetReceiver| Field Summary | |
|---|---|
protected java.lang.Class<E> |
elementClass
The Class of the elements of the collection. |
| Constructor Summary | |
|---|---|
CollectionReceiver(java.lang.Class<E> elementClass)
Creates a CollectionReceiver for some constructible element
class. |
|
| Method Summary | |
|---|---|
static java.lang.Class<?> |
acceptableElementClass(java.lang.Class<?> elementClass)
Given a Class representing the elements of some collection, this
method determines whether it counts as constructible (either via
ConstructorReceiver or via StringConstructorReceiver). |
static java.lang.Class<?> |
acceptableElementClass(java.lang.reflect.ParameterizedType collectionType)
Given a ParameterizedType, this method examines its parameter to
determine if it's a constructible type (either via
ConstructorReceiver or via StringConstructorReceiver). |
protected abstract T |
createCollection(java.util.List<E> elements)
Converts the raw sequence of form objects to a collection. |
T |
finished()
Converts all of the received form data into the appropriate product type. |
FormElementReceiver |
index(int index)
Returns an appropriate FormElementReceiver for the
index'th element of the collection, creating it if necessary. |
FormElementReceiver |
key(java.lang.String field)
Ignores keys - the collection itself has no key fields. |
void |
values(java.lang.Iterable<java.lang.String> values)
Applies a value sequence to the collection. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final java.lang.Class<E> elementClass
Class of the elements of the collection.
| Constructor Detail |
|---|
public CollectionReceiver(java.lang.Class<E> elementClass)
CollectionReceiver for some constructible element
class.
elementClass - the class of the elements of the collection.| Method Detail |
|---|
public static java.lang.Class<?> acceptableElementClass(java.lang.reflect.ParameterizedType collectionType)
ParameterizedType, this method examines its parameter to
determine if it's a constructible type (either via
ConstructorReceiver or via StringConstructorReceiver).
collectionType - the ParameterizedType representing the full collection type to
create.
Class of the elements of the collection, or
null if the collection would not contain
constructible elements.public static java.lang.Class<?> acceptableElementClass(java.lang.Class<?> elementClass)
Class representing the elements of some collection, this
method determines whether it counts as constructible (either via
ConstructorReceiver or via StringConstructorReceiver).
elementClass - the element class to examine.
null if
elementClass is not a constructible class.public FormElementReceiver index(int index)
FormElementReceiver for the
index'th element of the collection, creating it if necessary.
This method can create "sparse" collections: for lists and other
sequential collection types, any indices not given values will be left
null.
index in interface FormElementReceiverindex - the index to decode.
FormElementReceiver.index(int)public FormElementReceiver key(java.lang.String field)
key in interface FormElementReceiverfield - the field to decode.
FormElementReceiver.key(java.lang.String)public void values(java.lang.Iterable<java.lang.String> values)
values in interface FormElementReceivervalues - the values to store.FormElementReceiver.values(java.lang.Iterable)public T finished()
createCollection(List) to convert the
received collection into the target type.
finished in interface FormReceiver<T>FormReceiver.finished()protected abstract T createCollection(java.util.List<E> elements)
index(int)) or in iteration order (for
collections populated via values(Iterable).
elements - the collection contents.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||