List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:ductive.stats.StatsUtils.java
private static Map<String, String[][]> subqueries(String[][] paths) { if (ArrayUtils.isEmpty(paths)) return null; Map<String, String[][]> subqueries = new HashMap<>(); for (String[] path : paths) { if (ArrayUtils.isEmpty(path)) continue; String name = path[0];/*from w w w. j av a 2s . co m*/ String[][] subquery = subqueries.get(name); if (subquery != null || !subqueries.containsKey(name)) { String[] subarray = ArrayUtils.subarray(path, 1, path.length); if (ArrayUtils.isEmpty(subarray)) subqueries.put(name, null); else subqueries.put(name, ArrayUtils.add(subquery, subarray)); } } return subqueries; }
From source file:com.liveramp.hank.coordinator.Hosts.java
public static RuntimeStatisticsAggregator computeRuntimeStatisticsForDomain( Map<Domain, RuntimeStatisticsAggregator> runtimeStatistics, Domain domain) { if (runtimeStatistics.containsKey(domain)) { return runtimeStatistics.get(domain); } else {/*w w w. ja va2s. co m*/ return new RuntimeStatisticsAggregator(); } }
From source file:com.net2plan.utils.CollectionUtils.java
/** * Returns a map where each entry represents the number of times that the * corresponding key appears in the input collection. * * @param <A> Key type/*from w ww .j a va 2 s . c o m*/ * @param collection Input collection * @return Map where the key is an item appearing in the input collection, and the value is the number of times that appears */ public static <A> Map<A, Integer> count(Collection<A> collection) { Map<A, Integer> out = new LinkedHashMap<A, Integer>(); for (A value : collection) out.put(value, out.containsKey(value) ? out.get(value) + 1 : 1); return out; }
From source file:controllers.OldSensorReadingController.java
private static String getDateFormat() { String dateFormat = null;/*from ww w. j a va 2 s . co m*/ final Map<String, String[]> entries = request().queryString(); if (!entries.isEmpty() && entries.containsKey("dateformat")) { dateFormat = entries.get("dateformat")[0]; } return dateFormat; }
From source file:com.foobnix.api.vkontakte.VkOld.java
public static VkAudio search(String text, Context context) throws VKAuthorizationException { LOG.d("Search FModel by text", text); List<VkAudio> list = searchAll(text, context); Map<String, Integer> bestTimes = new HashMap<String, Integer>(); int maxCount = 0; VkAudio result = null;/*w ww . j av a 2 s. c o m*/ // find best time for (VkAudio model : list) { String key = model.getDuration(); if (bestTimes.containsKey(key)) { Integer value = bestTimes.get(key); value++; bestTimes.put(key, value); if (value > maxCount) { maxCount = value; result = model; } } else { bestTimes.put(key, 1); } } return result; }
From source file:com.ms.commons.test.classloader.util.VelocityTemplateUtil.java
public static String mergeContent(final Map<Object, Object> context, String text) { StringReader sr = new StringReader(text); StringWriter sw = new StringWriter(); Context c = new Context() { public boolean containsKey(Object key) { return context.containsKey(key); }// w ww. j a va 2 s .c o m public Object get(String key) { return context.get(key); } public Object[] getKeys() { return context.keySet().toArray(); } public Object put(String key, Object value) { return context.put(key, value); } public Object remove(Object key) { return context.remove(key); } }; try { VELOCITY_ENGINE.evaluate(c, sw, VelocityTemplateUtil.class.getSimpleName(), sr); } catch (Exception e) { throw new RuntimeException(e); } return sw.toString(); }
From source file:com.net2plan.utils.CollectionUtils.java
/** * Returns a map of selected elements from the input map. It is not backed * in the input map, thus changes in the returned one are not reflected in the * input map./*from w ww . ja v a2 s . com*/ * * @param <A> Key type * @param <B> Value type * @param map Input map * @param keys Keys of the elements to be selected. * @return Map containing the entries corresponding to the keys in the input set (in iteration order) */ public static <A, B> Map<A, B> selectEntries(Map<A, B> map, Set<A> keys) { Map<A, B> out = new LinkedHashMap<A, B>(); for (A key : keys) if (map.containsKey(key)) out.put(key, map.get(key)); return out; }
From source file:com.msopentech.odatajclient.engine.communication.request.batch.ODataBatchUtilities.java
/** * Retrieves item type from item headers. * * @param headers batch item headers.//from w w w . jav a 2s . c om * @return batch item type. */ public static BatchItemType getItemType(final Map<String, Collection<String>> headers) { final BatchItemType nextItemType; final String contentType = headers.containsKey(ODataHeaders.HeaderName.contentType.toString()) ? headers.get(ODataHeaders.HeaderName.contentType.toString()).toString() : StringUtils.EMPTY; if (contentType.contains(ODataBatchConstants.MULTIPART_CONTENT_TYPE)) { nextItemType = BatchItemType.CHANGESET; } else if (contentType.contains(ODataBatchConstants.ITEM_CONTENT_TYPE)) { nextItemType = BatchItemType.RETRIEVE; } else { nextItemType = BatchItemType.NONE; } LOG.debug("Retrieved next item type {}", nextItemType); return nextItemType; }
From source file:com.phoenixnap.oss.ramlapisync.naming.SchemaHelper.java
/** * Utility method that will return a schema if the identifier is valid and exists in the raml file definition. * /*from w ww . jav a2s .c o m*/ * @param schema The name of the schema to resolve * @param document The Parent Raml Document * @return The full schema if contained in the raml document or null if not found */ public static String resolveSchema(String schema, Raml document) { if (document == null || schema == null || schema.indexOf("{") != -1) { return null; } if (document.getSchemas() != null && !document.getSchemas().isEmpty()) { for (Map<String, String> map : document.getSchemas()) { if (map.containsKey(schema)) { return map.get(schema); } } } return null; }
From source file:com.wavemaker.runtime.server.ServerUtils.java
/** * Get the method parameter from the parameters map; as a side effect, remove that entry. * /*from w ww . jav a2s . c om*/ * @param params The map - this is side-effected, and the method entry is removed. * @return The method to invoke. */ public static String getMethod(Map<String, Object[]> params) { String method = null; if (params.containsKey(ServerConstants.METHOD)) { Object methodO = params.get(ServerConstants.METHOD); if (methodO instanceof String[]) { if (1 == ((String[]) methodO).length) { method = ((String[]) methodO)[0]; } } } if (method == null) { throw new WMRuntimeException(MessageResource.SERVER_NOMETHODORID, params); } params.remove(ServerConstants.METHOD); return method; }