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

java.lang.Object
  extended by ca.grimoire.formtree.receiver.constructor.StringConstructorReceiver<T>
Type Parameters:
T - the type of the object to create.
All Implemented Interfaces:
FormElementReceiver, FormReceiver<T>

public class StringConstructorReceiver<T>
extends java.lang.Object
implements FormReceiver<T>

A form receiver that uses constructors with the signature (String). The first value passed to values(Iterable) will be used to populate the field; other values will be ignored.


Constructor Summary
StringConstructorReceiver(java.lang.Class<T> valueClass)
          Creates a StringConstructorReceiver that creates instances of valueClass.
 
Method Summary
static boolean accepts(java.lang.Class<?> formClass)
          Checkes whether StringConstructorReceiver is able to construct instances of a given class.
static
<T> StringConstructorReceiver<T>
create(java.lang.Class<T> parameterType)
          A type-inferring alternative to calling StringConstructorReceiver(Class).
 T finished()
          Notifies the receiver that form decoding has finished.
 FormElementReceiver index(int index)
          Adds an index to the decoded form.
 FormElementReceiver key(java.lang.String field)
          Adds a key to the decoded form.
 void values(java.lang.Iterable<java.lang.String> values)
          Add a terminal value to the decoded form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringConstructorReceiver

public StringConstructorReceiver(java.lang.Class<T> valueClass)
Creates a StringConstructorReceiver that creates instances of valueClass. This class must have a constructor whose signature is (String).

Parameters:
valueClass - the class of the product to create.
Method Detail

accepts

public static boolean accepts(java.lang.Class<?> formClass)
Checkes whether StringConstructorReceiver is able to construct instances of a given class. StringConstructorReceiver can construct any class that has a constructor with the signature (String).

Parameters:
formClass - the class to interrogate.
Returns:
true if StringConstructorReceiver can create formClass.

create

public static <T> StringConstructorReceiver<T> create(java.lang.Class<T> parameterType)
A type-inferring alternative to calling StringConstructorReceiver(Class).

Type Parameters:
T - the type of the value to construct.
Parameters:
parameterType - the class of <T>
Returns:
a new StringConstructorReceiver.

finished

public T finished()
Description copied from interface: FormReceiver
Notifies the receiver that form decoding has finished.

Specified by:
finished in interface FormReceiver<T>
Returns:
the result of the form decoding process.

key

public FormElementReceiver key(java.lang.String field)
Description copied from interface: FormElementReceiver
Adds a key to the decoded form.

Specified by:
key in interface FormElementReceiver
Parameters:
field - the field to decode.
Returns:
a form receiver for the key's contents.

index

public FormElementReceiver index(int index)
Description copied from interface: FormElementReceiver
Adds an index to the decoded form.

Specified by:
index in interface FormElementReceiver
Parameters:
index - the index to decode.
Returns:
a form receiver for the index's contents.

values

public void values(java.lang.Iterable<java.lang.String> values)
Description copied from interface: FormElementReceiver
Add a terminal value to the decoded form.

Specified by:
values in interface FormElementReceiver
Parameters:
values - the values to store.


Copyright © 2011 Grimoire Alchymia. All Rights Reserved.