List of usage examples for java.util Map.Entry get
V get(Object key);
From source file:com.mac.holdempoker.app.hands.Set.java
private Card[] findSet() { List<Card> trips = new ArrayList(); List<Card> singles = new ArrayList(); for (Map.Entry<Rank, List<Card>> entry : cards.entrySet()) { if (entry.getValue().size() == 3 && trips.size() == 0) { trips = entry.getValue();//from w w w.j ava2s .c o m } else if (entry.getValue().size() == 1 && singles.size() < 2) { singles.add(entry.getValue().get(0)); } } if (trips.size() == 3 && singles.size() == 2) { return (Card[]) CollectionUtils.union(trips, singles).toArray(new Card[5]); } else { return null; } }
From source file:org.apache.apex.malhar.lib.window.accumulation.AbstractPojoJoin.java
private Map<String, Object> pojoToMap(Object input, int streamIndex) { Map<String, Object> map = new HashMap<>(); Map<String, PojoUtils.Getter> gettersStream = streamIndex == 1 ? gettersStream1 : gettersStream2; for (Map.Entry<String, PojoUtils.Getter> getter : gettersStream.entrySet()) { try {//from ww w. j a v a2s . com Object value = getter.getValue().get(input); map.put(getter.getKey(), value); } catch (Exception e) { throw Throwables.propagate(e); } } return map; }
From source file:org.apache.apex.malhar.lib.join.POJOInnerJoinOperator.java
/** * Merge the given tuples/*ww w . j a v a 2 s . c o m*/ * @param tuple1 tuple belongs to stream1 * @param tuple2 tuple belongs to stream1 * @return the merged output object */ @Override public Object mergeTuples(Object tuple1, Object tuple2) { Object o; try { o = outputClass.newInstance(); for (Map.Entry<PojoUtils.Getter, PojoUtils.Setter> g : inputFieldObjects[0].fieldMap.entrySet()) { g.getValue().set(o, g.getKey().get(tuple1)); } for (Map.Entry<PojoUtils.Getter, PojoUtils.Setter> g : inputFieldObjects[1].fieldMap.entrySet()) { g.getValue().set(o, g.getKey().get(tuple2)); } } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } return o; }
From source file:at.ac.tuwien.inso.subcat.ui.controller.DistributionChartController.java
private Map<String, Object> getVariables(DistributionChart.ChartIdentifier identifier) { assert (identifier != null); Map<String, Object> map = viewController.getVariables(); map.put("year", view.getSelectedYear()); for (Map.Entry<DropDownData, Integer> entry : identifier.getSelectedFilterConfigs().entrySet()) { String name = entry.getKey().getConfig().getVariableName(); Integer value = entry.getKey().getData().get(entry.getValue()).id; map.put(name, value);/* w w w. jav a 2 s . c om*/ } return map; }
From source file:org.apache.unomi.services.services.EventServiceImpl.java
@SuppressWarnings("unchecked") private void getEventProperties(Map<String, Map<String, Object>> mappings, List<EventProperty> props, String prefix) {// w w w . j a v a2s . c om for (Map.Entry<String, Map<String, Object>> e : mappings.entrySet()) { if (e.getValue().get("properties") != null) { getEventProperties((Map<String, Map<String, Object>>) e.getValue().get("properties"), props, prefix + e.getKey() + "."); } else { props.add(new EventProperty(prefix + e.getKey(), (String) e.getValue().get("type"))); } } }
From source file:cn.cnic.bigdatalab.flume.sink.mongodb.MappingDefinition.java
private void populateDateFormatField(Map.Entry<String, JsonNode> entry, DateFieldDefinition fieldDefinition) { if (entry.getValue().has(DATE_FORMAT)) { fieldDefinition.setDateFormat(entry.getValue().get(DATE_FORMAT).asText()); }/* w w w .ja va2s. com*/ }
From source file:org.wso2.carbon.message.flow.tracer.services.MessageFlowTracerAdminService.java
public MessageFlowTraceEntry[] getMessageFlows() { MessageFlowTraceDataStore messageFlowTraceDataStore = (MessageFlowTraceDataStore) getConfigContext() .getProperty(MessageFlowTraceConstants.MESSAGE_FLOW_TRACE_STORE); List<MessageFlowTraceEntry> entries = new ArrayList<>(); Map<String, List<MessageFlowTraceEntry>> messageFlows = messageFlowTraceDataStore.getMessageFlowDataHolder() .getMessageFlows();//w w w. j a v a 2 s .c o m for (Map.Entry<String, List<MessageFlowTraceEntry>> entry : messageFlows.entrySet()) { if (entry.getValue() != null && entry.getValue().size() > 0) { entries.add(entry.getValue().get(0)); } } if (messageFlows.values().size() == 0) { return new MessageFlowTraceEntry[1]; } return entries.toArray(new MessageFlowTraceEntry[entries.size()]); }
From source file:net.jforum.services.GroupService.java
/** * Save the permissions for this group/*from ww w .jav a 2 s . co m*/ */ @SuppressWarnings("unchecked") public void savePermissions(int groupId, Map<String, Map<String, List<?>>> map) { Group group = this.repository.get(groupId); RoleManager currentRoles = new RoleManager(); currentRoles.setGroups(Arrays.asList(group)); group.getRoles().clear(); boolean isAdministrator = currentRoles.isAdministrator(); boolean canManageForums = currentRoles.roleExists(SecurityConstants.CAN_MANAGE_FORUMS); boolean isCoAdministrator = currentRoles.isCoAdministrator(); List<Integer> groups = new ArrayList<Integer>(); for (int gid : currentRoles.getRoleValues(SecurityConstants.GROUPS)) { groups.add(gid); } boolean canInteractwithOtherGroups = currentRoles.roleExists(SecurityConstants.INTERACT_OTHER_GROUPS); boolean isSuperAdministrator = this.userSession.getRoleManager().isAdministrator(); for (Map.Entry<String, List<?>> entry : map.get("boolean").entrySet()) { String key = entry.getKey(); Boolean value = (Boolean) entry.getValue().get(0); if (SecurityConstants.ADMINISTRATOR.equals(key)) { registerRole(group, key, isSuperAdministrator ? value : isAdministrator); } else if (SecurityConstants.CAN_MANAGE_FORUMS.equals(key)) { registerRole(group, key, isSuperAdministrator ? value : canManageForums); } else if (SecurityConstants.CO_ADMINISTRATOR.equals(key)) { registerRole(group, key, isSuperAdministrator ? value : isCoAdministrator); } else if (SecurityConstants.INTERACT_OTHER_GROUPS.equals(key)) { registerRole(group, key, isSuperAdministrator ? value : canInteractwithOtherGroups); } else { registerRole(group, key, (Boolean) entry.getValue().get(0)); } } for (Map.Entry<String, List<?>> entry : map.get("multiple").entrySet()) { String key = entry.getKey(); List<Integer> value = (List<Integer>) entry.getValue(); if (SecurityConstants.GROUPS.equals(key)) { registerRole(group, key, isSuperAdministrator ? value : groups); } else { registerRole(group, key, value); } } this.repository.update(group); this.sessionManager.computeAllOnlineModerators(); //this.userRepository.changeAllowAvatarState(map.getCanHaveProfilePicture(), group); }
From source file:org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexRootDirectory.java
/** * Returns the most recent directory for each index. If for an index 2 versions are present * then it would return the most recent version *//*from w w w . j av a 2s.c om*/ public List<LocalIndexDir> getAllLocalIndexes() throws IOException { Map<String, List<LocalIndexDir>> mapping = getIndexesPerPath(); List<LocalIndexDir> result = Lists.newArrayListWithCapacity(mapping.size()); for (Map.Entry<String, List<LocalIndexDir>> e : mapping.entrySet()) { result.add(e.getValue().get(0)); } return result; }
From source file:io.anserini.search.SearchCollection.java
@SuppressWarnings("unchecked") public <K> int runTopics() throws IOException { IndexSearcher searcher = new IndexSearcher(reader); searcher.setSimilarity(similarity);//from w ww . ja v a 2s . co m Path topicsFile = Paths.get(args.topics); if (!Files.exists(topicsFile) || !Files.isRegularFile(topicsFile) || !Files.isReadable(topicsFile)) { throw new IllegalArgumentException( "Topics file : " + topicsFile + " does not exist or is not a (readable) file."); } TopicReader<K> tr; SortedMap<K, Map<String, String>> topics; try { tr = (TopicReader<K>) Class.forName("io.anserini.search.query." + args.topicReader + "TopicReader") .getConstructor(Path.class).newInstance(topicsFile); topics = tr.read(); } catch (Exception e) { throw new IllegalArgumentException("Unable to load topic reader: " + args.topicReader); } final String runTag = "Anserini_" + args.topicfield + "_" + (args.keepstop ? "KeepStopwords_" : "") + FIELD_BODY + "_" + (args.searchtweets ? "SearchTweets_" : "") + similarity.toString(); PrintWriter out = new PrintWriter( Files.newBufferedWriter(Paths.get(args.output), StandardCharsets.US_ASCII)); for (Map.Entry<K, Map<String, String>> entry : topics.entrySet()) { K qid = entry.getKey(); String queryString = entry.getValue().get(args.topicfield); ScoredDocuments docs; if (args.searchtweets) { docs = searchTweets(searcher, qid, queryString, Long.parseLong(entry.getValue().get("time"))); } else { docs = search(searcher, qid, queryString); } /** * the first column is the topic number. * the second column is currently unused and should always be "Q0". * the third column is the official document identifier of the retrieved document. * the fourth column is the rank the document is retrieved. * the fifth column shows the score (integer or floating point) that generated the ranking. * the sixth column is called the "run tag" and should be a unique identifier for your */ for (int i = 0; i < docs.documents.length; i++) { out.println(String.format(Locale.US, "%s Q0 %s %d %f %s", qid, docs.documents[i].getField(FIELD_ID).stringValue(), (i + 1), docs.scores[i], ((i == 0 || i == docs.documents.length - 1) ? runTag : "See_Line1"))); } } out.flush(); out.close(); return topics.size(); }