package com.atlassian.bitbucket.mirroring.mirror;

import javax.annotation.Nonnull;

/**
 * @since 4.3
 */
public enum MirroringMode {
    ALL_PROJECTS,
    SELECTED_PROJECTS;

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

    @Nonnull
    public static MirroringMode fromId(String id) {
        for (MirroringMode mode : values()) {
            if (mode.getId().equalsIgnoreCase(id)) {
                return mode;
            }
        }

        throw new IllegalArgumentException("Unknown MirrorMode: " + id);
    }
}
