org.qi4j.api.value
Interface ValueBuilderFactory

All Known Subinterfaces:
Module

public interface ValueBuilderFactory

Factory for Values and ValueBuilders.


Method Summary
<T> T
newValue(java.lang.Class<T> valueType)
          Instantiate a Value of the given type.
<T> ValueBuilder<T>
newValueBuilder(java.lang.Class<T> valueType)
          Create a builder for creating new Values that implements the given Value type.
<T> ValueBuilder<T>
newValueBuilderWithPrototype(T prototype)
          Create a builder for creating a new Value starting with the given prototype.
<T> ValueBuilder<T>
newValueBuilderWithState(java.lang.Class<T> mixinType, Function<PropertyDescriptor,java.lang.Object> propertyFunction, Function<AssociationDescriptor,EntityReference> associationFunction, Function<AssociationDescriptor,java.lang.Iterable<EntityReference>> manyAssociationFunction)
          Create a builder for creating a new Value starting with the given state.
<T> T
newValueFromSerializedState(java.lang.Class<T> valueType, java.lang.String serializedState)
          Instantiate a Value of the given type using the serialized state given as String.
 

Method Detail

newValue

<T> T newValue(java.lang.Class<T> valueType)
           throws NoSuchValueException,
                  ConstructionException
Instantiate a Value of the given type.

Parameters:
valueType - the Value type to instantiate
Returns:
a new Value instance
Throws:
NoSuchValueException - if no value extending the mixinType has been registered
ConstructionException - if the value could not be instantiated

newValueBuilder

<T> ValueBuilder<T> newValueBuilder(java.lang.Class<T> valueType)
                                throws NoSuchValueException
Create a builder for creating new Values that implements the given Value type.

The returned ValueBuilder can be reused to create several Values instances.

Parameters:
valueType - an interface that describes the Composite to be instantiated
Returns:
a ValueBuilder for creation of ValueComposites implementing the interface
Throws:
NoSuchValueException - if no value extending the mixinType has been registered

newValueBuilderWithPrototype

<T> ValueBuilder<T> newValueBuilderWithPrototype(T prototype)
Create a builder for creating a new Value starting with the given prototype.

The returned ValueBuilder can only be used ONCE.

Parameters:
prototype - a prototype the builder will use
Returns:
a ValueBuilder for creation of ValueComposites implementing the interface of the prototype
Throws:
NoSuchValueException - if no value extending the mixinType has been registered

newValueBuilderWithState

<T> ValueBuilder<T> newValueBuilderWithState(java.lang.Class<T> mixinType,
                                             Function<PropertyDescriptor,java.lang.Object> propertyFunction,
                                             Function<AssociationDescriptor,EntityReference> associationFunction,
                                             Function<AssociationDescriptor,java.lang.Iterable<EntityReference>> manyAssociationFunction)
Create a builder for creating a new Value starting with the given state.

The returned ValueBuilder can only be used ONCE.

Parameters:
mixinType - an interface that describes the Composite to be instantiated
propertyFunction - a function providing the state of properties
associationFunction - a function providing the state of associations
manyAssociationFunction - a function providing the state of many associations
Returns:
a ValueBuilder for creation of ValueComposites implementing the interface
Throws:
NoSuchValueException - if no value extending the mixinType has been registered

newValueFromSerializedState

<T> T newValueFromSerializedState(java.lang.Class<T> valueType,
                                  java.lang.String serializedState)
Instantiate a Value of the given type using the serialized state given as String.

Parameters:
valueType - the Value type to instantiate
serializedState - the state of the Value
Returns:
a new Value instance
Throws:
NoSuchValueException - if no value extending the mixinType has been registered
ConstructionException - if the value could not be instantiated