package com.atlassian.bitbucket.internal.branch.automerge;

import javax.annotation.Nonnull;

/**
 * Represents a status of an auto-merge process being attempted for a given branch.
 *
 * @since 2.8
 */
public enum AutoMergeStatus {

    /**
     * Automatic merge can be performed.
     */
    PROCEED(true),

    /**
     * Automatic merge functionality is disabled for given repository
     */
    AUTO_MERGE_DISABLED(false),

    /**
     * Merge path cannot be calculated at all (e.g. branch model is not enabled).
     */
    CANNOT_CALCULATE_PATH(false),

    /**
     * There is no merge path for given branch.
     */
    NO_PATH(false),

    /**
     * The calculated path is too long to attempt.
     */
    PATH_TOO_LONG(false);

    private final boolean available;

    private AutoMergeStatus(boolean available) {
        this.available = available;
    }

    @Nonnull
    public String getId() {
        return name();
    }

    /**
     * @return {@code true}, if the automatic merge is available for given branch and can proceed,
     * {@code false} otherwise
     */
    public boolean isAvailable() {
        return available;
    }
}
