
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 DayOfWeek implements EnumBase {
    MONDAY("1"),
    TUESDAY("2"),
    WEDNESDAY("3"),
    THURSDAY("4"),
    FRIDAY("5"),
    SATURDAY("6"),
    SUNDAY("7");

    @JsonValue
    private final String code;

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