package com.dji.sdk.cloudapi.device;

import com.dji.sdk.exception.CloudSDKException;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Arrays;

/**
 * @author sean
 * @version 1.4
 * @date 2023/2/28
 */
public enum DockModeCodeEnum {

    IDLE(0, "空闲中"),

    DEBUGGING(1, "现场调试"),

    REMOTE_DEBUGGING(2, "远程调试"),

    UPGRADING(3, "固件升级中"),

    WORKING(4, "作业中");

    private final int code;

    private final String text;

    DockModeCodeEnum(int code,String text) {
        this.code = code;
        this.text   = text;
    }

    @JsonValue
    public int getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    @JsonCreator
    public static DockModeCodeEnum find(int code) {
        return Arrays.stream(values()).filter(modeCode -> modeCode.code == code).findAny()
                .orElseThrow(() -> new CloudSDKException(DockModeCodeEnum.class, code));
    }
}
