List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:Main.java
public static boolean containsAll(Map map, List keys) { for (Object key : keys) { if (!map.containsKey(key)) { return false; }/* w ww . j av a 2 s.co m*/ } return true; }
From source file:Main.java
/** * This method allows you to add a value to a list that is contained * in a map. If the key is not already in the map it is create and a * new (@link ArrayList} is started. //from w ww . j ava 2 s . c om * @param mapArrayList * @param key * @param value */ public static <K, V> void addToMappedArrayList(Map<K, List<V>> mapArrayList, K key, V value) { if (!mapArrayList.containsKey(key)) { mapArrayList.put(key, new ArrayList<V>()); } mapArrayList.get(key).add(value); }
From source file:Main.java
final static public boolean containsKey(Map<Object, Object> collection, Object item) { return collection != null && collection.containsKey(item); }
From source file:Main.java
public static <T> List<T> unwrap(Map<String, List<T>> response, String key) { if (response != null && response.containsKey(key) && response.get(key) != null) { return response.get(key); } else {//from ww w . ja va 2s .c om return new ArrayList<>(); } }
From source file:Main.java
public static <T> List<T> unwrapResponse(Map<String, List<T>> response, String key) { if (response != null && response.containsKey(key) && response.get(key) != null) { return response.get(key); } else {//from w w w.ja v a2 s.co m return new ArrayList<>(); } }
From source file:Main.java
public static String mapGetValueIgnoringCase(java.util.Map<String, String> map, String key) { if (map.containsKey(key)) { return map.get(key); }/*w w w. ja va 2 s . co m*/ for (String f : map.keySet()) { if (equalsIgnoreCase(f, key)) { return map.get(f); } } return null; }
From source file:Main.java
public static boolean mapContainsKeyIgnoringCase(Map<String, String> map, String key) { if (map.containsKey(key)) { return true; }//from w w w . j a v a2s.co m return collectionContainsIgnoringCase(map.keySet(), key); }
From source file:Main.java
public static final boolean containsKey(Object key) { Map<Object, Object> cache = LOCAL_CACHE.get(); return cache != null && cache.containsKey(key); }
From source file:Main.java
public static String getPrefix(final String namespace, final Map<String, String> namespacesPrefixesMap) { if (!namespacesPrefixesMap.containsKey(namespace)) { namespacesPrefixesMap.put(namespace, NAMESPACE_PREFIX_BASE + counter.incrementAndGet()); }//from w ww .ja va 2 s. c o m return namespacesPrefixesMap.get(namespace); }
From source file:Main.java
public static <K> void aggregateMaps(Map<K, Integer> A, Map<K, Integer> B) { for (K k : B.keySet()) { if (A.containsKey(k)) A.put(k, A.get(k) + B.get(k)); else/*from www.j a v a 2s .c o m*/ A.put(k, B.get(k)); } }