
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 TriggerMethod implements EnumBase {
    SCHEDULE("S"),
    EVENT("E");

    @JsonValue
    private final String code;

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