package com.bytesw.bytebot.model.enums;

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

public enum CalendarExceptionType {
    HOLIDAY("H"), WORK_EXCEPTION("W"), NO_WORK_EXCEPTION("N");

    private final String name;

    private static final Map<String, CalendarExceptionType> map = new HashMap<>();

    static {
        for (CalendarExceptionType type : CalendarExceptionType.values()) {
            map.put(type.name, type);
        }
    }

    CalendarExceptionType(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public static CalendarExceptionType fromString(String name) {
        if (map.containsKey(name)) {
            return map.get(name);
        }
        throw new NoSuchElementException(name + " not found");
    }
}