org.qi4j.api.value

## Interface ValueBuilderFactory

- All Known Subinterfaces:
    Module, ModuleSpi

      public interface ValueBuilderFactory

  Factory for Values and ValueBuilders.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> T` | `newValue(Class<T> valueType)` Instantiate a Value of the given type.
    `<T> ValueBuilder<T>` | `newValueBuilder(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(Class<T> mixinType, Function<PropertyDescriptor,Object> propertyFunction, Function<AssociationDescriptor,EntityReference> associationFunction, Function<AssociationDescriptor,Iterable<EntityReference>> manyAssociationFunction, Function<AssociationDescriptor,Map<String,EntityReference>> namedAssociationFunction)` Create a builder for creating a new Value starting with the given state.
    `<T> T` | `newValueFromSerializedState(Class<T> valueType, String serializedState)` Instantiate a Value of the given type using the serialized state given as String.

- - ### Method Detail

    - #### newValue

          <T> T newValue(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(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(Class<T> mixinType,
                                                     Function<PropertyDescriptor,Object> propertyFunction,
                                                     Function<AssociationDescriptor,EntityReference> associationFunction,
                                                     Function<AssociationDescriptor,Iterable<EntityReference>> manyAssociationFunction,
                                                     Function<AssociationDescriptor,Map<String,EntityReference>> namedAssociationFunction)

      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
        `namedAssociationFunction` - a function providing the state of named 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(Class<T> valueType,
                                          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