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.4
 * @date 2024/8/21
 */
public enum LayoutEnum {

    TOP_LEFT(0),

    BOTTOM_LEFT(1),

    TOP_RIGHT(2),

    BOTTOM_RIGHT(3),
    ;

    private final int layout;

    LayoutEnum(int layout) {
        this.layout = layout;
    }

    @JsonValue
    public int getState() {
        return layout;
    }

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