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

import com.atlassian.bitbucket.repository.Branch;

import javax.annotation.Nonnull;

/**
 * Represents a potential auto-merge for a specific branch. This can be either an actual auto-merge process involving
 * at least one merge along the {@link #getPath() merge path}, or a no-op in case this auto merge was calculated
 * for a branch, for which no merge path exists, or no merge path can be calculated.
 * <p>
 * The {@link #getPath()} path} is an ordered list of branches that can be auto-merged. The branch for which this
 * path was calculated is always at the head of the {@code path}.
 * <p>
 * If the {@link #getStatus() status} is indicating that auto merge should not be performed, {@code path} will
 * only contain a single element, which is the branch for which this auto merge was requested.
 *
 * @since 2.8
 */
public interface AutoMerge {

    /**
     * Get the status of the auto merge, indicating whether the auto merge operation for given branch should, or should
     * not proceed.
     *
     * @return status of auto-merge
     */
    @Nonnull
    AutoMergeStatus getStatus();

    /**
     * Get the merge path as flat iterable, starting with the branch, for which this auto merge was calculated.
     *
     * @return auto merge path
     */
    @Nonnull
    Iterable<Branch> getPath();
}
