package com.beanit.asn1dsrc.enums;

import java.util.HashMap;
import java.util.Map;

public enum eControlDevice {

    Control_Command       (0x01, "Control_Command"),
    Control_BasicInfo     (0x02, "Control_BasicInfo"),
    Control_StatusRequest (0x03, "Control_StatusRequest"),
    Control_InfoRequest   (0x04, "Control_InfoRequest"),
    Control_EnterDirInfo  (0x05, "Control_EnterDirInfo"),
    Control_DisconnectInfo(0x06, "Control_DisconnectInfo");

    private final int value;
    private final String string;

    private static final Map<Integer, eControlDevice> map;
    static {
        map = new HashMap<>();
        for (eControlDevice e : values()) {
            map.put(Integer.valueOf(e.value), e);
        }
    }
    public static eControlDevice getByValue(int value) {
        return map.get(Integer.valueOf(value));
    }
    public static eControlDevice getByValue(byte value) {
        int intValue = (int)(value & 0x0F);
        return map.get(Integer.valueOf(intValue));
    }

    eControlDevice(int value, String string) {
        this.value  = value;
        this.string = string;
    }

    public int getValue() {
        return this.value;
    }
    public String toString() {
        return this.string;
    }
}
