package com.acme.util.utilities;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class MapUtility
{
    public static Object getKeyFromValue(Map<?, ?> map, Object value)
    {
        List<Object> list = getKeysFromValue(map, value);
        if (list.size() > 0)
            return list.get(0);
        return null;
    }

    public static List<Object> getKeysFromValue(Map<?, ?> map, Object value)
    {
        List<Object> list = new ArrayList<Object>();
        for (Object o : map.keySet())
            if (map.get(o).equals(value))
                list.add(o);
        return list;
    }

}
