Java enum containing a hash map for look up I have the below enum. I need to get the description by code. It is working but can it be improved still? 

public enum Maps {

    COLOR_RED("ABC", "abc description");

    private final String code;
    private final String description;
    private static Map&lt;String, String&gt; mMap;

    private Maps(String code, String description) {
        this.code = code;
        this.description = description;
    }
    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }


    public static String getDescriptionByCode(String code) {
        if (mMap == null) {
            initializeMapping();
        }
        if (mMap.containsKey(code)) {
            return mMap.get(code);
        }
        return null;
    }

    private static void initializeMapping() {
        mMap = new HashMap&lt;String, String&gt;();
        for (Maps s : Maps.values()) {
            mMap.put(s.code, s.description);
        }
    }
}
Your code is very neat and clean, there is only one thing that I would change:

private static Map&lt;String, String&gt; mMap;


to

private static final Map&lt;String, String&gt; mMap = Collections.unmodifiableMap(initializeMapping());


The reasons:


By not declaring it final and not using a call to unmodifiableMap it is mutable, and it would be possible to modify the reference using reflection or to use .remove("ABC") on the map. Declaring it as final makes sure that the referenced map cannot change and unmodifiableMap makes sure that no changes can be done to the map itself.
Multi-threading issues. As it currently stands, if two threads would call the getDescriptionByCode method at the same time you would initialize the mapping twice, which is not needed.


This also of course requires a slight change in your initializeMapping():

private static Map&lt;String, String&gt; initializeMapping() {
    Map&lt;String, String&gt; mMap = new HashMap&lt;String, String&gt;();
    for (Maps s : Maps.values()) {
        mMap.put(s.code, s.description);
    }
    return mMap;
}


Besides this, it all looks good. Well done!