package com.face.global.enums;

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

import java.util.Arrays;

@AllArgsConstructor
public enum UserTypeEnum {
    SYS_USER("sysUser"), CUSTOMER("customer");

    @Getter
    private String code;

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

}
