
package dev.sonpx.loyalty.mcp.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 CounterBucket {
    CURRENT_BUCKET("CB"),
    PREVIOUS_BUCKET("PB"),
    PERIOD_BEFORE_LAST("PBL");

    @JsonValue
    private final String code;

    @JsonCreator
    public static CounterBucket fromCode(String code) {
        return Arrays.stream(values())
                .filter(e -> e.code.equalsIgnoreCase(code))
                .findFirst()
                .orElse(null);
    }
}
