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

se.fortnox.reactivewizard.db.transactions.StatementContext Maven / Gradle / Ivy

There is a newer version: 24.6.0
Show newest version
package se.fortnox.reactivewizard.db.transactions;

import se.fortnox.reactivewizard.db.statement.Statement;

import java.util.function.Supplier;

public final class StatementContext {
    private final Supplier statementSupplier;
    private final ConnectionScheduler connectionScheduler;
    private Runnable transactionCompletedAction;

    public StatementContext(Supplier statementSupplier, ConnectionScheduler connectionScheduler) {
        this.statementSupplier = statementSupplier;
        this.connectionScheduler = connectionScheduler;
    }

    public Statement getStatement() {
        return statementSupplier.get();
    }

    public ConnectionScheduler getConnectionScheduler() {
        return connectionScheduler;
    }

    public void onTransactionCompleted(Runnable action) {
        this.transactionCompletedAction = action;
    }

    void transactionCompleted() {
        if (this.transactionCompletedAction != null) {
            this.transactionCompletedAction.run();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy