List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:org.apache.streams.elasticsearch.ElasticsearchMetadataUtil.java
public static String getType(Map<String, Object> metadata, ElasticsearchReaderConfiguration config) { String type = null;//from www . j a va2 s . co m if (metadata != null && metadata.containsKey("type")) type = (String) metadata.get("type"); if (type == null) { type = config.getTypes().get(0); } return type; }
From source file:deck36.yaml.YamlLoader.java
public static Map updateMap(Map resultYamlMap, Map<String, Object> localYamlMap) { for (Map.Entry<String, Object> entry : localYamlMap.entrySet()) { if (resultYamlMap.containsKey(entry.getKey())) { System.out.println(entry.getKey()); try { Object startValue = resultYamlMap.get(entry.getKey()); Object updateValue = entry.getValue(); if (startValue == null) { resultYamlMap.put(entry.getKey(), updateValue); } else { resultYamlMap.put(entry.getKey(), MethodUtils.invokeStaticMethod(YamlLoader.class, "updateMap", new Object[] { startValue, updateValue })); }/* w w w . j a va 2 s . c o m*/ } catch (Exception e) { e.printStackTrace(); System.exit(1); } } else { resultYamlMap.put(entry.getKey(), entry.getValue()); } } return resultYamlMap; }
From source file:org.apache.streams.elasticsearch.ElasticsearchMetadataUtil.java
public static String getIndex(Map<String, Object> metadata, ElasticsearchWriterConfiguration config) { String index = null;/* www.j a va2 s . c o m*/ if (metadata != null && metadata.containsKey("index")) index = (String) metadata.get("index"); if (index == null || (config.getForceUseConfig() != null && config.getForceUseConfig())) { index = config.getIndex(); } return index; }
From source file:org.apache.streams.elasticsearch.ElasticsearchMetadataUtil.java
public static String getIndex(Map<String, Object> metadata, ElasticsearchReaderConfiguration config) { String index = null;/*from www. ja v a 2 s .co m*/ if (metadata != null && metadata.containsKey("index")) index = (String) metadata.get("index"); if (index == null) { index = config.getIndexes().get(0); } return index; }
From source file:jease.cms.service.Informatons.java
public static Map<Class<?>, Integer> getDatabaseClassCount() { Map<Class<?>, Integer> resultMap = new TreeMap<>(Comparator.comparing(Class::getName)); for (Persistent obj : Database.query(Persistent.class)) { Class<?> clazz = obj.getClass(); if (!resultMap.containsKey(clazz)) { resultMap.put(clazz, 0);// ww w . j a v a 2 s. c o m } resultMap.put(clazz, resultMap.get(clazz) + 1); } return resultMap; }
From source file:jvmoptions.OptionAnalyzer.java
@SafeVarargs static Map<String, String> pick(String key, Map<String, Map<String, String>>... maps) { for (Map<String, Map<String, String>> m : maps) { if (m.containsKey(key)) { return m.get(key); }/*from ww w . jav a2 s.co m*/ } throw new IllegalStateException("missing option " + key); }
From source file:com.l2jfree.gameserver.instancemanager.RaidPointsManager.java
public static void addPoints(L2Player player, int bossId, int points) { final Map<Integer, Integer> pointsByBossId = getList(player.getObjectId()); points += pointsByBossId.containsKey(bossId) ? pointsByBossId.get(bossId).intValue() : 0; pointsByBossId.put(bossId, points);/*from w w w . j av a 2 s .c o m*/ Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement; statement = con.prepareStatement( "REPLACE INTO character_raid_points (`charId`,`boss_id`,`points`) VALUES (?,?,?)"); statement.setInt(1, player.getObjectId()); statement.setInt(2, bossId); statement.setInt(3, points); statement.executeUpdate(); statement.close(); } catch (Exception e) { _log.fatal("could not update char raid points:", e); } finally { L2DatabaseFactory.close(con); } }
From source file:cop.raml.utils.javadoc.MethodJavaDoc.java
private static void addParameter(@NotNull String paramName, StringBuilder buf, Map<String, TagParam> params) { ThreadLocalContext.setParamName(paramName); if (params.containsKey(paramName)) ProblemResolver.methodParamDuplication(); else//w w w . j av a 2s . co m params.put(paramName, createTagParam(buf.toString(), TagLink.NULL)); }
From source file:com.oneops.search.msg.processor.CIMessageProcessor.java
private static void convertIllegalDateFormat(Map<String, String> ciAttributes, String name) { if (ciAttributes != null && ciAttributes.containsKey(name)) { String date = ciAttributes.get(name); //Nov 5 21:08:38 2019 GMT //Jan 22 18:21:47 2020 GMT // Some of the `expires_one` date fields apparently have date format with two spaces, so while this conversion is a hack, // until we migrate to newer ES version and change the mapping we need to accommodate both, since single DateTimeFormat can't handle it. DateTimeFormatter wrongFormat = DateTimeFormat.forPattern("MMM dd HH:mm:ss yyyy z"); DateTimeFormatter wrongFormat2 = DateTimeFormat.forPattern("MMM dd HH:mm:ss yyyy z"); /// 2020-01-22T18:21:47 DateTimeFormatter rightFormat = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss"); try {// w w w . j a v a 2 s. c o m ciAttributes.put(name, rightFormat.print(wrongFormat.parseMillis(date))); } catch (Exception e) { try { ciAttributes.put(name, rightFormat.print(wrongFormat2.parseMillis(date))); } catch (Exception ignore) { // do nothing, unexpected date format } } } }
From source file:eu.freme.broker.integration_tests.pipelines.PipelinesCommon.java
/** * Helper method that returns the content type of the response of the last request (or: the value of the 'accept' * header of the last request)./*from w ww . j a va 2 s . c om*/ * @param serializedRequests The requests that (will) serve as input for the pipelining service. * @return The content type of the response that the service will return. */ protected static RDFConstants.RDFSerialization getContentTypeOfLastResponse( final List<SerializedRequest> serializedRequests) { String contentType = ""; if (!serializedRequests.isEmpty()) { SerializedRequest lastRequest = serializedRequests.get(serializedRequests.size() - 1); Map<String, String> headers = lastRequest.getHeaders(); if (headers.containsKey("accept")) { contentType = headers.get("accept"); } else { Map<String, Object> parameters = lastRequest.getParameters(); if (parameters.containsKey("outformat")) { contentType = parameters.get("outformat").toString(); } } } RDFConstants.RDFSerialization serialization = RDFConstants.RDFSerialization.fromValue(contentType); return serialization != null ? serialization : RDFConstants.RDFSerialization.TURTLE; }