org.qi4j.api.entity
Interface EntityBuilder<T>


public interface EntityBuilder<T>

EntityBuilders are used to instantiate EntityComposites. They can be acquired from UnitOfWork.newEntityBuilder(Class) and allows the client to provide additional settings before instantiating the Composite. After calling newInstance() the builder becomes invalid, and may not be called again.


Method Summary
 T instance()
          Get a representation of the state for the new Composite.
<K> K
instanceFor(Class<K> mixinType)
          Get a representation of the state of the given type for the new Composite.
 T newInstance()
          Create a new Entity instance.
 

Method Detail

instance

T instance()
Get a representation of the state for the new Composite. It is possible to access and update properties and associations, even immutable ones since the builder represents the initial state.

Returns:
a proxy implementing the Composite type

instanceFor

<K> K instanceFor(Class<K> mixinType)
Get a representation of the state of the given type for the new Composite. This is primarily used if you want to provide state for a private mixin type.

Parameters:
mixinType - the mixin which you want to provide state for
Returns:
a proxy implementing the given mixin type

newInstance

T newInstance()
              throws ConstructionException,
                     LifecycleException
Create a new Entity instance.

Returns:
a new Entity instance
Throws:
ConstructionException - thrown if it was not possible to instantiate the Composite
LifecycleException - if the entity could not be created