All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.virtdata.core.ContextualBindingsMapTemplate Maven / Gradle / Ivy

There is a newer version: 2.12.15
Show newest version
package io.virtdata.core;

import io.virtdata.api.ValuesMapBinder;

/**
 * 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 ContextualBindingsMapTemplate {

    private C context;
    private BindingsTemplate bindingsTemplate;
    private ValuesMapBinder valuesArrayBinder;

    public ContextualBindingsMapTemplate(C context,
                                         BindingsTemplate bindingsTemplate,
                                         ValuesMapBinder valuesMapBinder) {
        this.context = context;
        this.bindingsTemplate = bindingsTemplate;
        this.valuesArrayBinder = valuesMapBinder;
    }

    public C getContext() {
        return context;
    }

    public BindingsTemplate getBindingsTemplate() {
        return bindingsTemplate;
    }

    public ValuesMapBinder getValuesArrayBinder() {
        return valuesArrayBinder;
    }

    public ContextualMapBindings resolveBindings() {
        Bindings bindings = bindingsTemplate.resolveBindings();
        return new ContextualMapBindings(bindings, context, valuesArrayBinder);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy