package io.delphiplatform.api.v3.model.datahealth;

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

import java.util.List;

import java.util.Arrays;

import io.delphiplatform.api.exception.InvalidParameterException;
import io.delphiplatform.api.v3.constant.RequestConstants;

public enum DataHealthStatus {

    MISSING("missing"),

    PENDING("pending"),

    PARTIAL("partial"),

    COMPLETE_MINIMAL("complete_minimal"),

    COMPLETE_VOLATILE("complete_volatile"),

    COMPLETE("complete");

    public static final List<DataHealthStatus> NO_DATA_STATUSES = List.of(MISSING, PENDING);

    private final String value;

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

    @JsonCreator
    public static DataHealthStatus fromValue(String value) {
        for (DataHealthStatus b : DataHealthStatus.values()) {
            if (b.value.equalsIgnoreCase(value)) {
                return b;
            }
        }
        throw new InvalidParameterException(RequestConstants.STATUS, Arrays.stream(DataHealthStatus.values()), value);
    }

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

    public String getDbValue() {
        return value.toUpperCase();
    }

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

