package com.its.vds.xnettcp.vds.protocol.enums;

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

public enum eVdsDetectErrorCode {

    DETECT_ERROR_NONE        (0x00, "0x00.NONE"),
    DETECT_ERROR_OSCILLATION (0x11, "0x11.Oscillation Error");

    private final int value;
    private final String string;

    private static final Map<Integer, eVdsDetectErrorCode> map;
    static {
        map = new HashMap<>();
        for (eVdsDetectErrorCode e : values()) {
            map.put(e.value, e);
        }
    }

    public static eVdsDetectErrorCode getValue(int value) {
        return map.get(value);
    }
    public static eVdsDetectErrorCode getValue(byte value) {
        int intValue = (value & 0xFF);
        return map.get(intValue);
    }

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

    public int getValue() {
        return this.value;
    }
    public byte getByteValue() {
        return (byte)(this.value & 0xFF);
    }

    @Override
    public String toString() {
        return this.string;
    }
}
