package com.atlassian.stash.internal.server;

import com.atlassian.bitbucket.server.Feature;

import javax.annotation.Nonnull;

/**
 * Dark {@link Feature features} provided by the application
 *
 * @since 4.7
 */
public enum DarkFeature implements Feature {

    NPS_INLINE_DIALOG("nps.survey.inline.dialog"),
    NPS_ENABLED_BY_SEN_EXPERIMENT("nps.experiment.enabled.by.sen");

    private final boolean dataCenter;
    private final String key;

    DarkFeature(String key) {
        this(key, false);
    }

    DarkFeature(String key, boolean dataCenter) {
        this.dataCenter = dataCenter;
        this.key = key;
    }

    @Nonnull
    public static DarkFeature fromKey(String value) {
        for (DarkFeature feature : values()) {
            if (feature.getKey().equals(value)) {
                return feature;
            }
        }
        throw new IllegalArgumentException("No Feature is associated with key [" + value + "]");
    }

    @Nonnull
    @Override
    public String getKey() {
        return key;
    }

    @Override
    public boolean isDataCenter() {
        return dataCenter;
    }
}
