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

io.axway.iron.Store Maven / Gradle / Ivy

The newest version!
package io.axway.iron;

import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import io.axway.iron.functional.Accessor;

/**
 * Permits to query and update the store data.
 */
public interface Store {
    /**
     * Query the store data thanks a {@link ReadonlyTransaction}.
     *
     * @param storeQuery the store query. The provided {@link ReadonlyTransaction} must not be used outside the scope of the query method.
     */
    void query(Consumer storeQuery);

    /**
     * Query the store data thanks a {@link ReadonlyTransaction} and return a result.
     *
     * @param storeQuery the store query. The provided {@link ReadonlyTransaction} must not be used outside the scope of the query method.
     * @param         the return type of the query
     * @return the result of the {@code storeQuery} function
     */
     T query(Function storeQuery);

    /**
     * Issue a transaction composed of a single command.
     *
     * @param commandClass the class of the command
     * @param  the class of command (automatically inferred)
     * @param  the return type of the command
     * @return a fluent interface to continue the call
     */
    , T> CommandBuilder createCommand(Class commandClass);

    /**
     * Begin a transaction that can be then populated with one or many command.
* A transaction is atomic, so if one the command fails, all the command of the transaction won't be executed, the updates until the failure will be rollbacked. * * @return a fluent interface to continue the call */ TransactionBuilder begin(); interface TransactionBuilder { /** * Add a new command in the transaction. * * @param commandClass the class of the command * @param the class of command (automatically inferred) * @param the return type of the command * @return a fluent interface to continue the call */ , T> CommandBuilder addCommand(Class commandClass); /** * Submit the transaction.
* The transaction commands are executed asynchronously. If the commands results are needed, they can be accessed through the returned {@code Future} object. * * @return a {@code Future} that gives access to the result of all the command, in the same order they have been added in the transaction. */ Future> submit(); } interface CommandBuilder, T> { /** * Begin the specification of a command parameter * * @param accessor the parameter accessor method reference * @param the type of value to be set * @return a fluent interface to continue the call */ CommandBuilderValueSetter set(Accessor accessor); CommandBuilder map(Object parameters); /** * Add the command to the transaction, or if it's a single command transaction submit the transaction with this command.
* The transaction commands are executed asynchronously. If the command result is needed, it can be accessed through the returned {@code Future} object. * * @return a {@code Future} that gives access to the result of the command */ Future submit(); } interface CommandBuilderValueSetter, T, V> { /** * Specify the command parameter value. * * @param value the value of the parameter * @return a fluent interface to continue the call */ CommandBuilder to(V value); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy