package io.delphiplatform.api.v3.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * Contains available `group_by` values related to streams, artist followers or other data.
 */
public enum GroupByField {

    DATE("date"),
    SUB_DSP("sub_dsp"),
    COUNTRY("country");

    private final String value;

    GroupByField(String value) {
        this.value = value;
    }

    @JsonCreator
    public static GroupByField fromValue(String value) {
        for (GroupByField b : GroupByField.values()) {
            if (b.value.equals(value)) {
                return b;
            }
        }
        throw new IllegalArgumentException("Unexpected value '" + value + "'");
    }

    @JsonValue
    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return String.valueOf(value);
    }
}
