
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 ScheduleMonthType implements EnumBase {
    DAY_OF_MONTH("DOM"),
    DAY_OF_WEEK("DOW");

    @JsonValue
    private final String code;

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