
package dev.sonpx.loyalty.mcp.enums.schedule;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import dev.sonpx.loyalty.mcp.enums.EnumBase;
import java.util.Arrays;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum DayOfMonth implements EnumBase {
    DAY01("1"),
    DAY02("2"),
    DAY03("3"),
    DAY04("4"),
    DAY05("5"),
    DAY06("6"),
    DAY07("7"),
    DAY08("8"),
    DAY09("9"),
    DAY10("10"),
    DAY11("11"),
    DAY12("12"),
    DAY13("13"),
    DAY14("14"),
    DAY15("15"),
    DAY16("16"),
    DAY17("17"),
    DAY18("18"),
    DAY19("19"),
    DAY20("20"),
    DAY21("21"),
    DAY22("22"),
    DAY23("23"),
    DAY24("24"),
    DAY25("25"),
    DAY26("26"),
    DAY27("27"),
    DAY28("28"),
    DAY29("29"),
    DAY30("30"),
    DAY31("31");

    @JsonValue
    private final String code;

    @JsonCreator
    public static DayOfMonth fromCode(String code) {
        return Arrays.stream(values())
                .filter(day -> day.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }
}
