package com.atlassian.bitbucket.scm.git.command.revlist;

import javax.annotation.Nullable;

/**
 * Enumerates the possible orders for {@code git rev-list}, controlling use of the {@code --date-order}
 * and {@code --topo-order} flags.
 */
public enum GitRevListOrder {

    /**
     * Similar to {@link #TOPOLOGICAL --topo-order} in the sense that no parent comes before all of its children,
     * but otherwise things are still ordered in the commit timestamp order.
     */
    DATE("--date-order"),
    /**
     * Apply {@code git rev-list}'s default behaviour.
     */
    DEFAULT,
    /**
     * Output the commits in topological order (i.e. descendant commits are shown before their parents).
     */
    TOPOLOGICAL("--topo-order");

    private final String flag;

    GitRevListOrder() {
        flag = null;
    }

    GitRevListOrder(String flag) {
        this.flag = flag;
    }

    @Nullable
    public String getFlag() {
        return flag;
    }

    public boolean isFlagged() {
        return flag != null;
    }
}
