
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;

/**
 * Created by SonPhung on Wednesday, 20-Dec-2023
 */
@Getter
@RequiredArgsConstructor
public enum CounterResetType {
    RESET_TO_REMAINDER("R"),
    RESET_TO_ZERO("Z");

    @JsonValue
    private final String code;

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