io.virtdata.core.ContextualBindingsTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-realer Show documentation
Show all versions of virtdata-lib-realer Show documentation
With inspiration from other libraries
The newest version!
package io.virtdata.core;
import io.virtdata.api.ValuesBinder;
/**
* A template that maps a set of specifiers, a context object, and a method for applying
* mapped values to the context object. This can be used in the configuration phase, in global
* scope without triggering mapper bindings resolution from specifiers.
*
* @param The type of the contextual template object.
* @param The type which will be produced when mapped values are applied to a type C
*/
public class ContextualBindingsTemplate {
private C context;
private BindingsTemplate bindingsTemplate;
private ValuesBinder valuesBinder;
public ContextualBindingsTemplate(C context,
BindingsTemplate bindingsTemplate,
ValuesBinder valuesMapBinder) {
this.context = context;
this.bindingsTemplate = bindingsTemplate;
this.valuesBinder = valuesMapBinder;
}
public C getContext() {
return context;
}
public BindingsTemplate getBindingsTemplate() {
return bindingsTemplate;
}
public ValuesBinder getValuesBinder() {
return valuesBinder;
}
public ContextualBindings resolveBindings() {
Bindings bindings = bindingsTemplate.resolveBindings();
return new ContextualBindings(bindings, context, valuesBinder);
}
}