List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:Main.java
public static boolean checkExternalSDExists() { Map<String, String> evn = System.getenv(); return evn.containsKey("SECONDARY_STORAGE"); }
From source file:Main.java
private static final void add(Map<Integer, List<String>> mapTo_addTo, int keyNum, String value) { if (mapTo_addTo.containsKey(keyNum)) { mapTo_addTo.get(keyNum).add(value); } else {/*from ww w .j ava2 s.co m*/ List<String> strList = new ArrayList<String>(); strList.add(value); mapTo_addTo.put(keyNum, strList); } }
From source file:Main.java
public static <K, V> void add(Map<K, List<V>> map, K key, V value) { if (map.containsKey(key)) { map.get(key).add(value);/*from w w w. ja v a2 s . co m*/ } else { List<V> list = new ArrayList<>(); list.add(value); map.put(key, list); } }
From source file:Main.java
static Node getElementById(Document doc, String id, Map<String, Node> idMap) { if (!idMap.containsKey(id)) { registerIDs(doc, doc.getDocumentElement(), idMap); }/*from www.ja va 2s. c om*/ return idMap.get(id); }
From source file:Main.java
public static Map<Object, Object> get(List<Map<Object, Object>> list, Object key) { for (Map<Object, Object> map : list) { if (map.containsKey(key)) { return map; }// w w w. j av a 2 s . c o m } return null; }
From source file:Main.java
public static <K, V> SortedSet<V> getEntryOrEmptySet(K key, Map<K, SortedSet<V>> map) { return (map.containsKey(key) ? map.get(key) : new TreeSet<V>()); }
From source file:Main.java
public static <K> void increaseCount(Map<K, Integer> map, K key, int amount) { if (!map.containsKey(key)) { map.put(key, 0);/*from w ww . j a v a2 s.c o m*/ } Integer total = map.get(key); total += amount; map.put(key, total); }
From source file:Main.java
public static void decrementLongMap(Map<String, Long> map, String key) { if (!map.containsKey(key)) return;//from w ww . j a va2 s . com map.put(key, map.get(key) - 1); }
From source file:Main.java
/** * Increase counter.get(key) by increase. * If value decrease to zero, it is removed from map. *//* w w w.java 2s .c o m*/ public static <K> void increaseMapCounter(Map<K, Integer> counter, K key, int increase) { if (!counter.containsKey(key)) { counter.put(key, 0); } counter.put(key, counter.get(key) + increase); if (counter.get(key) == 0) { counter.remove(key); } }
From source file:Main.java
public static <T> T getMapValue(Map<? extends Object, T> args, Object key, T defaultValue) { if (args.containsKey(key)) { return args.get(key); } else {//from w w w . jav a2 s .com return defaultValue; } }