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

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Arrays;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum DeductionPriorityType {
    START_DATE("STA"),
    EXPIRY_DATE("EXP"),
    CONTRIBUTOR("CON");

    @JsonValue
    private final String code;

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