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

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

public enum eVdsErrorCode {

    ERROR_NONE     (0x00, "0x00.NONE"),
    ERROR_OCCURRED (0x01, "0x01.ERROR");

    private final int value;
    private final String string;

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

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

    eVdsErrorCode(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;
    }
}
