wangmengmeng
2024-12-24 24432a361d5c6bd6f3d8c008693e9f1155d62517
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.dji.sdk.cloudapi.control;
 
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/3/14
 */
public enum JoystickInvalidReasonEnum {
 
    RC_LOST(0, "The remote controller is lost."),
 
    BATTERY_LOW_GO_HOME(1, "Due to low battery, the drone automatically returned home."),
 
    BATTERY_SUPER_LOW_LANDING(2, "Due to the serious low battery, the drone landed automatically."),
 
    NEAR_BOUNDARY(3, "The drone is near a not-fly zone."),
 
    RC_AUTHORITY(4, "The remote controller grabs control authority.");
 
    private final int reason;
 
    private final String message;
 
    JoystickInvalidReasonEnum(int reason, String message) {
        this.reason = reason;
        this.message = message;
    }
 
    @JsonValue
    public int getVal() {
        return reason;
    }
 
    public String getMessage() {
        return message;
    }
 
    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static JoystickInvalidReasonEnum find(int reason) {
        return Arrays.stream(values()).filter(reasonEnum -> reasonEnum.reason == reason).findAny()
                .orElseThrow(() -> new CloudSDKException(JoystickInvalidReasonEnum.class, reason));
    }
}