List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:com.datastax.sparql.ConsoleCompiler.java
private static void printHelp(final int exitCode) throws IOException { final Map<String, String> env = System.getenv(); final String command = env.containsKey("LAST_COMMAND") ? env.get("LAST_COMMAND") : "sparql-gremlin.sh"; printWithHeadline("Usage Examples", String.join("\n", command + " -f examples/modern1.sparql", command + " < examples/modern2.sparql", command + " <<< 'SELECT * WHERE { ?a e:knows ?b }'", command + " -g crew < examples/crew1.sparql")); if (exitCode >= 0) { System.exit(exitCode);/*from w w w . ja v a2s. c om*/ } }
From source file:Main.java
public static <K, V> Map<K, V> putAndCreateTreeMapIfAbsent(Map<K, V> map, K key, V value) { if (map == null) { map = new TreeMap<K, V>(); map.put(key, value);//from w w w . j a v a 2 s. co m } else if (!map.containsKey(key)) { map.put(key, value); } return map; }
From source file:Main.java
@SuppressWarnings("unchecked") public static void filtrerDoublonsSurPlace(List objets) { Map objetsDejaPresents = new HashMap(); for (Iterator i = objets.iterator(); i.hasNext();) { Object objet = i.next();//from ww w. j a va 2 s . c o m if (!objetsDejaPresents.containsKey(objet)) objetsDejaPresents.put(objet, null); else i.remove(); } }
From source file:flink.benchmark.AdvertisingTopologyNative.java
private static String getKafkaTopic(Map conf) { if (!conf.containsKey("kafka.topic")) { throw new IllegalArgumentException("No kafka topic found!"); }/*w w w . jav a2s . c o m*/ return (String) conf.get("kafka.topic"); }
From source file:flink.benchmark.AdvertisingTopologyNative.java
private static String getRedisHost(Map conf) { if (!conf.containsKey("redis.host")) { throw new IllegalArgumentException("No redis host found!"); }//w w w .j av a 2s . com return (String) conf.get("redis.host"); }
From source file:flink.benchmark.AdvertisingTopologyNative.java
private static String getZookeeperServers(Map conf) { if (!conf.containsKey("zookeeper.servers")) { throw new IllegalArgumentException("Not zookeeper servers found!"); }/*from w w w. ja va2 s .com*/ return listOfStringToString((List<String>) conf.get("zookeeper.servers"), String.valueOf(conf.get("zookeeper.port"))); }
From source file:Main.java
public static String[] intersect(String[] arr1, String[] arr2) { Map<String, Boolean> map = new HashMap<>(); LinkedList<String> list = new LinkedList<>(); for (String str : arr1) { if (!map.containsKey(str)) { map.put(str, Boolean.FALSE); }/* ww w. j av a 2s .co m*/ } for (String str : arr2) { if (map.containsKey(str)) { map.put(str, Boolean.TRUE); } } for (Map.Entry<String, Boolean> e : map.entrySet()) { if (e.getValue().equals(Boolean.TRUE)) { list.add(e.getKey()); } } String[] result = {}; return list.toArray(result); }
From source file:com.memetix.gun4j.expand.UrlExpander.java
public static String expand(final String shortUrl) throws Exception { if (shortUrl != null) { final StringBuilder sb = new StringBuilder(); sb.append(PARAM_NAME);//from w w w . j av a 2 s . c o m sb.append(EQUALS); sb.append(URLEncoder.encode(shortUrl, ENCODING)); Map<String, String> results = parseResponse(post(SERVICE_URL, sb.toString())); if (results.containsKey(shortUrl)) return results.get(shortUrl); else return shortUrl.toString(); } else { return null; } }
From source file:melnorme.utilbox.tests.CommonTestExt.java
protected static <K, V> void checkMapContains(Map<K, V> map, K key, V expectedValue) { assertTrue(map.containsKey(key)); V value = map.remove(key);/*from www . ja v a2 s . c om*/ assertAreEqual(value, expectedValue); }
From source file:Main.java
public static <K, V> void putIfAbsent(Map<K, V> from, Map<K, ? super V> to) { if (from == null || to == null) { return;//from ww w. j a va 2 s . c om } for (Entry<K, V> entry : from.entrySet()) { if (!to.containsKey(entry.getKey())) { to.put(entry.getKey(), entry.getValue()); } } }