package com.dji.sample.wayline.model.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author huiqing.jiang
 * @version 1.3
 * @date 2024/9/29
 */
public enum WaylinePrecisionTypeEnum {

    RTK(1, "高精度RTK任务"),

    GNSS(0, "GPS任务");

    int val;

    String type;

    WaylinePrecisionTypeEnum(int val, String type) {
        this.val = val;
        this.type = type;
    }

    @JsonValue
    public int getVal() {
        return val;
    }

    @JsonValue
    public String getType() {
        return type;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static WaylinePrecisionTypeEnum find(Integer val) {
        return Arrays.stream(values()).filter(waylinePrecisionTypeEnum -> waylinePrecisionTypeEnum.val == val).findAny().orElse(null);
    }

    public static Optional<WaylinePrecisionTypeEnum> find(String type) {
        return Arrays.stream(values()).filter(waylinePrecisionTypeEnum -> waylinePrecisionTypeEnum.type.equals(type)).findAny();
    }
}
