List of usage examples for java.util Map containsKey
boolean containsKey(Object key);
From source file:com.epam.catgenome.util.Utils.java
/** * Helper method to check if Map of Chromosome to String chromosome name contains specified String chromosome name, * taking into account variations in chromosome naming * @param chromosomeMap a Map of Chromosome to String chromosome name * @param chromosomeName a name of a chromosome * @return true if Chromosome from Map of Chromosome to String chromosome name contains specified chromosome name, * taking into account variations in chromosome naming *///from w w w .j a va2 s . c o m public static boolean chromosomeMapContains(Map<String, Chromosome> chromosomeMap, String chromosomeName) { return chromosomeMap.containsKey(chromosomeName) || chromosomeMap.containsKey(changeChromosomeName(chromosomeName)); }
From source file:com.ms.commons.test.tool.ExportDatabaseData.java
private static void addFields(Map<String, TableFields> map, List<TableFields> tableFieldList) { for (TableFields tfs : tableFieldList) { if (map.containsKey(tfs.getTable())) { map.get(tfs.getTable()).getFields().addAll(tfs.getFields()); } else {//from w w w .j av a2 s. co m map.put(tfs.getTable(), tfs); } } }
From source file:com.screenslicer.core.scrape.ProcessPage.java
private static Results perform(Element body, int page, String query, Leniency leniency, boolean trim, Map<String, Object> cache) { if (WebApp.DEBUG) { System.out.println("-Perform-> " + "leniency=" + leniency.name() + "; trim=" + trim); }/*from www. j a va 2 s . c o m*/ Extract.Cache extractCache = cache.containsKey("extractCache") ? (Extract.Cache) cache.get("extractCache") : new Extract.Cache(); cache.put("extractCache", extractCache); List<Integer> scores = new ArrayList<Integer>(); List<Results> results = new ArrayList<Results>(); List<Node> ignore = new ArrayList<Node>(); List<Node> nodes; if (!cache.containsKey("extractedNodes")) { nodes = new ArrayList<Node>(); cache.put("extractedNodes", nodes); for (int i = 0; i < NUM_EXTRACTIONS;) { List<Node> best = Extract.perform(body, page, ignore, extractCache); if (best.isEmpty()) { break; } for (Node node : best) { i++; nodes.add(node); ignore.add(node); } } } else { nodes = (List<Node>) cache.get("extractedNodes"); } int pos = 0; for (Node node : nodes) { Results curResults = createResults(body, page, node, pos++, leniency, query, trim, cache); results.add(curResults); scores.add(curResults.fieldScore(false, trim)); } int max = CommonUtil.max(scores); for (int i = 0; i < results.size(); i++) { if (results.get(i) != null && scores.get(i) == max) { if (WebApp.DEBUG) { System.out.println("-->results" + (i + 1)); } return results.get(i); } } if (!results.isEmpty() && results.get(0) != null) { return results.get(0); } return Results.resultsNull; }
From source file:org.grails.datastore.mapping.core.DatastoreUtils.java
/** * Process all Datastore Sessions that have been registered for deferred close * for the given SessionFactory.//w w w . j a v a2s. c o m * @param datastore the Datastore to process deferred close for * @see #initDeferredClose * @see #releaseSession */ public static void processDeferredClose(Datastore datastore) { Assert.notNull(datastore, "No Datastore specified"); Map<Datastore, Set<Session>> holderMap = deferredCloseHolder.get(); if (holderMap == null || !holderMap.containsKey(datastore)) { throw new IllegalStateException("Deferred close not active for Datastore [" + datastore + "]"); } logger.debug("Processing deferred close of Datastore Sessions"); Set<Session> sessions = holderMap.remove(datastore); for (Session session : sessions) { closeSession(session); } if (holderMap.isEmpty()) { deferredCloseHolder.set(null); } }
From source file:info.mikaelsvensson.devtools.analysis.shared.AbstractLog.java
private static <X extends AbstractSample> Map<String, Collection<X>> groupSamples(SampleGrouper sampleGrouper, SampleFilter sampleFilter, Collection<X> samples) { Map<String, Collection<X>> map = new TreeMap<String, Collection<X>>(); for (X sample : samples) { String groupName = sampleGrouper.getGroupName(sample); if (sampleFilter == null || sampleFilter.accepts(sample)) { if (!map.containsKey(groupName)) { map.put(groupName, new LinkedList<X>()); }//from w w w . j a va 2 s . co m map.get(groupName).add(sample); } } return map; }
From source file:com.liveramp.cascading_ext.counters.Counters.java
public static Map<FlowStepStats, List<Counter>> getCountersByStep(FlowStats flowStats) { Map<FlowStepStats, List<Counter>> counters = new HashMap<FlowStepStats, List<Counter>>(); for (FlowStepStats statsForStep : flowStats.getFlowStepStats()) { if (!counters.containsKey(statsForStep)) { counters.put(statsForStep, Lists.<Counter>newArrayList()); }//from w ww . j a v a 2 s. c o m counters.get(statsForStep).addAll(getStatsFromStep(statsForStep, null)); } for (Map.Entry<FlowStepStats, List<Counter>> entry : counters.entrySet()) { Collections.sort(entry.getValue()); } return counters; }
From source file:net.ontopia.topicmaps.cmdlineutils.Consistify.java
protected static void removeDuplicates(TopicMapIF tm) { Map keymap = new HashMap(); AssociationIF[] assocs = new AssociationIF[tm.getAssociations().size()]; tm.getAssociations().toArray(assocs); for (int i = 0; i < assocs.length; i++) { AssociationIF assoc = assocs[i]; String key = KeyGenerator.makeAssociationKey(assoc); if (keymap.containsKey(key)) { System.out.println("Removing: " + key); // If map contains key remove this association assoc.remove();//from ww w . j a v a 2 s . c o m } else { keymap.put(key, null); } } }
From source file:io.lavagna.service.PermissionServiceTest.java
private static Set<Permission> permissionsForRole(Map<String, RoleAndPermissions> l, Role role) { Set<Permission> perms = new HashSet<>(); if (l.containsKey(role.getName())) { for (RoleAndPermission rap : l.get(role.getName()).getRoleAndPermissions()) { perms.add(rap.getPermission()); }// w ww.j a va2s . c o m } return perms; }
From source file:com.enonic.vertical.adminweb.handlers.preview.PreviewPageHandler.java
private static boolean isArrayFormItem(Map formItems, String string) { if (!formItems.containsKey(string)) { return false; }/*from ww w. j a va 2 s. co m*/ if (formItems.get(string) == null) { return false; } return formItems.get(string).getClass() == String[].class; }
From source file:edu.cmu.cs.lti.util.general.BasicConvenience.java
/** * Check that a map (usually a Properties instance) has certain keys defined. * /*from w w w . java 2 s . c o m*/ * @param the * map to check the keys * @param the * keys to check * @throws IllegalArgumentException * if any of the keys is missing */ public static void checkDefinedKeys(Map map, String... keys) throws IllegalArgumentException { for (String key : keys) if (!map.containsKey(key)) throw new IllegalArgumentException("Undefined mandatory key '" + key + "'"); }