package cd.casic.module.machine.enums;


import cd.casic.framework.commons.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum AuthenticationType implements IntArrayValuable {
    PASSWORD(1,"密码认证"),
    SECRET_KEY(2,"密钥认证");

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AuthenticationType::getCode).toArray();
    private final int code;

    private final String message;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static AuthenticationType of(int code) {
        if (code == 0) {
            return null;
        }
        for (AuthenticationType value : values()) {
            if (value.code==code) {
                return value;
            }
        }
        return null;
    }

}
