package com.face.global.enums;

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

import java.util.Arrays;

@AllArgsConstructor
public enum UserStatusEnum {
    NORMAL("1"), LOCK("2");

    @Getter
    private String code;

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