package com.dji.sdk.cloudapi.wayline;

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

import java.util.Arrays;

/**
 * @author sean
 * @version 1.7
 * @date 2023/10/11
 */
public enum LastPointTypeEnum {

    OVER_THE_HOME_POINT(0),

    NOT_OVER_THE_HOME_POINT(1),

    /** 固件未就绪/无效时常见哨兵值（如 65535） */
    UNKNOWN(65535);

    private final int type;

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

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

    @JsonCreator
    public static LastPointTypeEnum find(int type) {
        return Arrays.stream(values()).filter(typeEnum -> typeEnum.type == type).findAny()
                .orElse(UNKNOWN);
    }

}
