/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		System.out.println(Messages.isMessageInGroup("Another Message"));
	}
	
}

enum Messages {

    MESSAGE_1("Message", "Category"),
    MESSAGE_2("Another Message", "Category"),
    MESSAGE_3("Odd Message", "Another Category");

    private static final Map<String, Set<String>> map;
    static {
        Map<String, Set<String>> tempMap = new HashMap<>();
        for (Messages m : Messages.values()) {
            tempMap.computeIfAbsent(m.category, s -> new HashSet<>()).add(m.message);
        }
        map = Collections.unmodifiableMap(tempMap);
    }

    private final String message, category;

    private Messages(String message, String category) {
        this.message = message;
        this.category = category;
    }

    public String getMessage() { return message; }
    public String getCategory() { return category; }

    public static boolean isMessageInGroup(String message){
        // use `getOrDefault` if `get` could return null!!
        return map.get("Category").contains(message);
    }
    public static Set<String> messagesInGroup(String category) {
    	return Collections.unmodifiableSet(
        	map.getOrDefault(category, Collections.emptySet())
    	);
	}
}