package com.tsi.comm.server.protocol.enums;

import lombok.Getter;

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

public enum eLightsStatus {

    LIGHTS_OUT   (0, "LIGHTS_OUT"),     //소등
    RED_SOLID    (1, "RED_SOLID"),      //적색점등
    YELLOW_SOLID (2, "YELLOW_SOLID"),   //황색점등
    GREEN_SOLID  (3, "GREEN_SOLID"),    //녹색점등
    RED_BLINK    (4, "RED_BLINK"),      //적색점멸
    YELLOW_BLINK (5, "YELLOW_BLINK"),   //황색점멸
    GREEN_BLINK  (6, "GREEN_BLINK");    //녹색점멸

    @Getter
    private final int value;
    private final String string;

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

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

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