StateValues.java 2.17 KB
package pl.itcrowd.youtrack.api.defaults;

public enum StateValues {
    Submitted,
    Open,
    InProgress("{In Progress}", "In Progress"),
    ToBeDiscussed("{To be discussed}", "To be discussed"),
    Reopened,
    CantReproduce("{Can't Reproduce}", "Can't Reproduce"),
    Duplicate,
    Fixed,
    WontFix("{Won't fix}", "Won't fix"),
    Incomplete,
    Obsolete,
    Verified,
    New,
    NotSubmitted(true, Submitted),
    NotOpen(true, Open),
    NotInProgress(true, InProgress),
    NotToBeDiscussed(true, ToBeDiscussed),
    NotReopened(true, Reopened),
    NotCantReproduce(true, CantReproduce),
    NotDuplicate(true, Duplicate),
    NotFixed(true, Fixed),
    NotWontFix(true, WontFix),
    NotIncomplete(true, Incomplete),
    NotObsolete(true, Open),
    NotVerified(true, Verified),
    NotNew(true, New),
    Resolved("Resolved", null),
    Unresolved("Unresolved", null);

// ------------------------------ FIELDS ------------------------------

    private String commandValue;

    private String filterValue;

    private boolean not;

// --------------------------- CONSTRUCTORS ---------------------------

    private StateValues()
    {
        this(false);
    }

    private StateValues(boolean not)
    {
        this(not, null, null);
    }

    private StateValues(String filterValue, String commandValue)
    {
        this(false, filterValue, commandValue);
    }

    private StateValues(boolean not, StateValues value)
    {
        this(not, value.getFilterValue(), value.getCommandValue());
    }

    private StateValues(boolean not, String filterValue, String commandValue)
    {
        this.not = not;
        this.filterValue = filterValue == null ? name() : filterValue;
        this.commandValue = commandValue == null ? name() : commandValue;
    }

// ------------------------ CANONICAL METHODS ------------------------

    @Override
    public String toString()
    {
        return getCommandValue();
    }

// -------------------------- OTHER METHODS --------------------------

    public String getCommandValue()
    {
        return (not ? "-" : "") + commandValue;
    }

    public String getFilterValue()
    {
        return (not ? "-" : "") + filterValue;
    }
}