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

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

import java.util.Arrays;

/**
 * @author sean
 * @version 1.9
 * @date 2024/7/26
 */
public enum FlightPointTypeEnum {

    //起飞点
    HOME(0),

    //飞行轨迹
    HAND(1),

    //航线轨迹
    WAYLINE(2),

    //图片轨迹
    PICTURE(3)

    ;

    private final int type;

    FlightPointTypeEnum(int type) {
        this.type = type;
    }

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

    @JsonCreator
    public static FlightPointTypeEnum find(int type) {
        return Arrays.stream(values()).filter(flightPointTypeEnum -> flightPointTypeEnum.type==type).findAny()
            .orElseThrow(() -> new RuntimeException("This FlightPointType(" + type + ") is not supported."));
    }
}
