
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 WeekOfMonth implements EnumBase {
    FIRST("1"),
    SECOND("2"),
    THIRD("3"),
    FOURTH("4"),
    FIFTH("5"),
    LAST("L");

    @JsonValue
    private final String code;

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