package com.face.global.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;

@AllArgsConstructor
public enum YesOrNoEnum {
    YES("1"), NO("0");

    @Getter
    private String code;

    public static YesOrNoEnum codeOf(String codeArg) {
        return Arrays.stream(YesOrNoEnum.values()).filter(value ->
                        StringUtils.equals(codeArg, value.name())
                                || StringUtils.equals(codeArg, value.getCode()))
                .findAny().orElse(null);
    }

}
