package com.sikey.wa04.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

/**
 * 定位类型
 */
@Getter
@AllArgsConstructor
@ToString
public enum LocationType {
    /**
     * 基站
     */
    BASE_STATION("0","3"),
    /**
     * WIFI
     */
    WIFI("1","2"),
    /**
     * GPS
     */
    GPS("2","1");

    private final String value;

    private final String targetValue;

    public static LocationType valueOfValue(String value) {
        for (LocationType locationType : values()) {
            if (locationType.value.equals(value)) {
                return locationType;
            }
        }
        throw new RuntimeException("Unknown location type: " + value);
    }

    public static LocationType targetValueOf(Integer targetValue) {
        String val = targetValue.toString();
        for (LocationType locationType : values()) {
            if (locationType.targetValue.equals(val)) {
                return locationType;
            }
        }
        throw new RuntimeException("Unknown location type: " + targetValue);
    }
}
