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 sean
 * @version 1.3
 * @date 2022/9/26
 */
public enum WaylineTemplateTypeEnum {


    WAYPOINT(0, "航点航线","waypoint"),

    MAPPING_2D(1, "二维正射","mapping2d"),

    MAPPING_3D(2, "倾斜摄影","mapping3d"),

    MAPPING_STRIP(3, "带状航线","mappingStrip"),

    UNKNOWN(-1, "未知","");

    int val;

    private final String text;
    private final String type;

    WaylineTemplateTypeEnum(int value,String text, String type) {
        this.val = value;
        this.type = type;
        this.text = text;
    }

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

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

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

    public static WaylineTemplateTypeEnum find(String type) {
        return Arrays.stream(values()).filter(templateTypeEnum -> templateTypeEnum.type.equalsIgnoreCase(type)).findAny().orElse(UNKNOWN);
    }
}
