DeviceChannelEnum.java 870 Bytes
package cn.com.glsx.smart.common.enums;

/**
 * <p>Description:
 * <p>Project: chejia-smart
 *
 * @author wbh
 * @date 2021-04-27
 */
public enum DeviceChannelEnum {
    TU_YA((byte) 1, "access_platform_tuya"),
    AQARA((byte) 2, "access_platform_aqara"),
    DIDIHU((byte) 0, "access_platform_didihu")
    ;

    private final Byte channel;
    private final String platformKey;

    DeviceChannelEnum(Byte channel, String platformKey) {
        this.channel = channel;
        this.platformKey = platformKey;
    }

    public static Byte getChannelByPlatformKey(String platformKey) {
        Byte channel = values()[0].channel;
        for (DeviceChannelEnum value : values()) {
            if (value.platformKey.equalsIgnoreCase(platformKey)) {
                channel = value.channel;
                break;
            }
        }
        return channel;
    }
}