package com.atlassian.bitbucket.mesh.transaction;

/**
 * @see TransactionManager#prepared(PreparedAction)
 */
public enum PrepareResult {

    ABSTAIN(false, false),
    FAILURE(true, false),
    SUCCESS(true, true);

    private final boolean binding;
    private final boolean success;

    PrepareResult(boolean binding, boolean success) {
        this.binding = binding;
        this.success = success;
    }

    /**
     * @return {@code true} if this vote should count toward whether the {@link TransactionManager#prepared prepared}
     *         write operation should commit; otherwise, {@code false} if this vote should be disregarded
     */
    public boolean isBinding() {
        return binding;
    }

    /**
     * @return {@code true} if the system is ready to commit the {@link TransactionManager#prepared prepared} write
     *         operation; otherwise, {@code false}
     */
    public boolean isSuccess() {
        return success;
    }
}
