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 hqjiang
 * @version 1.0
 * @date 2024/8/28
 * 标定类型
 */
public enum SourceTypeEnum {

    NOT(0,"未标定"),

    SELF(1,"自收敛标定"),

    HAND(2,"手动标定"),

    RTK(3,"网络RTK标定");

    private final int sourceType;

    private final String text;

    SourceTypeEnum(int sourceType,String text) {
        this.sourceType = sourceType;
        this.text = text;
    }

    @JsonValue
    public int getControlSource() {
        return sourceType;
    }

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