Search in sources :

Example 1 with ValueBuilderWithState

use of org.qi4j.runtime.value.ValueBuilderWithState in project qi4j-sdk by Qi4j.

the class ModuleInstance method newValueBuilderWithState.

@Override
public <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) {
    NullArgumentException.validateNotNull("propertyFunction", propertyFunction);
    NullArgumentException.validateNotNull("associationFunction", associationFunction);
    NullArgumentException.validateNotNull("manyAssociationFunction", manyAssociationFunction);
    NullArgumentException.validateNotNull("namedAssociationFunction", namedAssociationFunction);
    ModelModule<ValueModel> compositeModelModule = typeLookup.lookupValueModel(mixinType);
    if (compositeModelModule == null) {
        throw new NoSuchValueException(mixinType.getName(), name());
    }
    StateResolver stateResolver = new FunctionStateResolver(propertyFunction, associationFunction, manyAssociationFunction, namedAssociationFunction);
    return new ValueBuilderWithState<>(compositeModelModule, this, stateResolver);
}
Also used : NoSuchValueException(org.qi4j.api.value.NoSuchValueException) ValueModel(org.qi4j.runtime.value.ValueModel) ValueBuilderWithState(org.qi4j.runtime.value.ValueBuilderWithState) FunctionStateResolver(org.qi4j.runtime.composite.FunctionStateResolver) StateResolver(org.qi4j.runtime.composite.StateResolver) FunctionStateResolver(org.qi4j.runtime.composite.FunctionStateResolver)

Aggregations

NoSuchValueException (org.qi4j.api.value.NoSuchValueException)1 FunctionStateResolver (org.qi4j.runtime.composite.FunctionStateResolver)1 StateResolver (org.qi4j.runtime.composite.StateResolver)1 ValueBuilderWithState (org.qi4j.runtime.value.ValueBuilderWithState)1 ValueModel (org.qi4j.runtime.value.ValueModel)1