package com.atlassian.stash.internal.repository.sync.auto;

import javax.annotation.Nonnull;
import java.util.Locale;

/**
 * @since 3.3
 */
public enum AutoRefSyncOperation {

    REVIEW(1),
    SYNCHRONIZE(2);

    private final int id;

    private AutoRefSyncOperation(int id) {
        this.id = id;
    }

    @Nonnull
    public static AutoRefSyncOperation fromId(int id) {
        for (AutoRefSyncOperation value : values()) {
            if (value.getId() == id) {
                return value;
            }
        }
        throw new IllegalArgumentException("No AutoRefSyncOperation is associated with ID [" + id + "]");
    }

    public int getId() {
        return id;
    }

    @Override
    public String toString() {
        return name().toLowerCase(Locale.US);
    }
}
