package com.bytesw.bytebot.etl.enums;

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

public enum MessageTypeEnum {
    REJECTED("R"), ACCEPTED("A");

    private final String name;

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

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

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

    public String getName() {
        return name;
    }

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