List of usage examples for org.apache.commons.lang3.tuple Pair getRight
public abstract R getRight();
Gets the right element from this pair.
When treated as a key-value pair, this is the value.
From source file:com.github.steveash.jg2p.train.EncoderEval.java
private void printExamples() { for (Integer phoneEdit : examples.keySet()) { log.info(" ---- Examples with edit distance " + phoneEdit + " ----"); Iterable<Pair<InputRecord, List<PhoneticEncoder.Encoding>>> toPrint = limit(examples.get(phoneEdit), MAX_EXAMPLE_TO_PRINT);//from ww w . jav a 2 s . com for (Pair<InputRecord, List<PhoneticEncoder.Encoding>> example : toPrint) { String got = "<null>"; if (example.getRight().size() > 0) { got = example.getRight().get(0).toString(); } log.info(" Got: " + got + " expected: " + example.getLeft().getRight().getAsSpaceString()); } } }
From source file:com.spotify.heroic.cluster.ClusterManagerModule.java
@Provides @ClusterScope//from w w w . j av a 2s . c om public Map<String, RpcProtocol> protocols(List<Pair<String, RpcProtocolComponent>> protocols) { final Map<String, RpcProtocol> map = new HashMap<>(); for (final Pair<String, RpcProtocolComponent> m : protocols) { map.put(m.getLeft(), m.getRight().rpcProtocol()); } return map; }
From source file:com.Da_Technomancer.crossroads.API.packets.Message.java
@SuppressWarnings("unchecked") private final void writeField(Field f, Class clazz, ByteBuf buf) throws IllegalArgumentException, IllegalAccessException { Pair<Reader, Writer> handler = getHandler(clazz); handler.getRight().write(f.get(this), buf); }
From source file:de.tntinteractive.portalsammler.engine.MapReaderTest.java
@Test public void testTwoEntryMap() throws Exception { final String input = "test123\n" + " e1\n" + " w1\n" + " e2\n" + " w2\n" + "."; final MapReader r = createReader(input); final Pair<String, Map<String, String>> p = r.readNext(); assertEquals("test123", p.getLeft()); final Map<String, String> map = new LinkedHashMap<String, String>(); map.put("e1", "w1"); map.put("e2", "w2"); assertEquals(map, p.getRight()); assertNull(r.readNext());//from www . jav a2s . co m }
From source file:com.linkedin.pinot.tools.StarTreeIndexViewer.java
private int build(StarTreeIndexNodeInterf indexNode, StarTreeJsonNode json) { Iterator<? extends StarTreeIndexNodeInterf> childrenIterator = indexNode.getChildrenIterator(); if (!childrenIterator.hasNext()) { return 0; }/*from w w w .j a va2 s .c om*/ int childDimensionId = indexNode.getChildDimensionName(); String childDimensionName = dimensionNameToIndexMap.inverse().get(childDimensionId); Dictionary dictionary = dictionaries.get(childDimensionName); int totalChildNodes = indexNode.getNumChildren(); Comparator<Pair<String, Integer>> comparator = new Comparator<Pair<String, Integer>>() { @Override public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) { return -1 * Integer.compare(o1.getRight(), o2.getRight()); } }; MinMaxPriorityQueue<Pair<String, Integer>> queue = MinMaxPriorityQueue.orderedBy(comparator) .maximumSize(MAX_CHILDREN).create(); StarTreeJsonNode allNode = null; while (childrenIterator.hasNext()) { StarTreeIndexNodeInterf childIndexNode = childrenIterator.next(); int childDimensionValueId = childIndexNode.getDimensionValue(); String childDimensionValue = "ALL"; if (childDimensionValueId != StarTreeIndexNodeInterf.ALL) { childDimensionValue = dictionary.get(childDimensionValueId).toString(); } StarTreeJsonNode childJson = new StarTreeJsonNode(childDimensionValue); totalChildNodes += build(childIndexNode, childJson); if (childDimensionValueId != StarTreeIndexNodeInterf.ALL) { json.addChild(childJson); queue.add(ImmutablePair.of(childDimensionValue, totalChildNodes)); } else { allNode = childJson; } } //put ALL node at the end if (allNode != null) { json.addChild(allNode); } if (totalChildNodes > MAX_CHILDREN) { Iterator<Pair<String, Integer>> qIterator = queue.iterator(); Set<String> topKDimensions = new HashSet<>(); topKDimensions.add("ALL"); while (qIterator.hasNext()) { topKDimensions.add(qIterator.next().getKey()); } Iterator<StarTreeJsonNode> iterator = json.getChildren().iterator(); while (iterator.hasNext()) { StarTreeJsonNode next = iterator.next(); if (!topKDimensions.contains(next.getName())) { iterator.remove(); } } } return totalChildNodes; }
From source file:name.martingeisse.slave_services.babel.api.DownloadCakeTranslationFileApiHandler.java
@Override public void handle(final ApiRequestCycle requestCycle, final ApiRequestPathChain path) throws Exception { // parse request URI and load data if (path.isEmpty()) { throw new MissingRequestParameterException("domain"); }//from w w w.j a va 2 s .c om ApiRequestPathChain subpath1 = path.getTail(); if (subpath1.isEmpty()) { throw new MissingRequestParameterException("language key"); } String domain = path.getHead(); String languageKey = subpath1.getHead(); // TODO what about missing ones? List<Pair<MessageFamily, MessageTranslation>> translationEntries = BabelDataUtil .loadDomainTranslations(domain, languageKey, false); // parse options if ("1".equals(requestCycle.getRequest().getParameter("download"))) { requestCycle.getResponse().addHeader("Content-Disposition", "attachment; filename=" + domain + ".po"); } // build the response requestCycle.getResponse().addHeader("Content-Type", "text/plain"); StringBuilder builder = new StringBuilder(); for (Pair<MessageFamily, MessageTranslation> translationEntry : translationEntries) { // TODO quote escaping builder.append("msgid \"").append(translationEntry.getLeft().getMessageKey()); builder.append("\"\nmsgstr \"").append(translationEntry.getRight().getText()); builder.append("\"\n\n"); requestCycle.getResponse().getWriter().print(builder); builder.setLength(0); } }
From source file:cherry.sqlman.tool.statement.SqlStatementIdControllerImpl.java
@Override public ModelAndView execute(int id, SqlStatementForm form, BindingResult binding, Authentication auth, Locale locale, SitePreference sitePref, NativeWebRequest request) { if (hasErrors(form, binding)) { return withViewname(viewnameOfStart).build(); }//from w w w . j a va2 s.co m try { initializeForm(form, id, auth, false); Pair<PageSet, ResultSet> pair = search(form); return withViewname(viewnameOfStart).addObject(pair.getLeft()).addObject(pair.getRight()).build(); } catch (BadSqlGrammarException ex) { LogicalErrorUtil.reject(binding, LogicError.BadSqlGrammer, Util.getRootCause(ex).getMessage()); return withViewname(viewnameOfStart).build(); } }
From source file:controllers.admin.AttachmentsController.java
/** * Filters the attachment management table. *///w ww . j a v a 2 s .c o m public Result attachmentsFilter() { String uid = getUserSessionManagerPlugin().getUserSessionId(ctx()); FilterConfig<AttachmentManagementListView> filterConfig = this.getTableProvider() .get().attachmentManagement.filterConfig.persistCurrentInDefault(uid, request()); if (filterConfig == null) { return ok(views.html.framework_views.parts.table.dynamic_tableview_no_more_compatible.render()); } else { Pair<Table<AttachmentManagementListView>, Pagination<Attachment>> t = getTable(filterConfig); return ok(views.html.framework_views.parts.table.dynamic_tableview.render(t.getLeft(), t.getRight())); } }
From source file:cherry.example.web.applied.ex90.AppliedEx90ControllerImpl.java
@Override public ModelAndView confirm(AppliedEx90Form form, BindingResult binding, Authentication auth, Locale locale, SitePreference sitePref, NativeWebRequest request) { if (hasErrors(form, binding)) { return withViewname(viewnameOfStart).build(); }// w w w. j a va2 s. c om Pair<String, List<String>> temp = createTempFile(asList(form.getFile())); form.setDirname(temp.getLeft()); form.setNumOfFile(temp.getRight().size()); form.setOriginalFilename(form.getFile().getOriginalFilename()); return withoutView().build(); }
From source file:cherry.sqlman.tool.clause.SqlClauseIdControllerImpl.java
@Override public ModelAndView execute(int id, SqlClauseForm form, BindingResult binding, Authentication auth, Locale locale, SitePreference sitePref, NativeWebRequest request) { if (hasErrors(form, binding)) { return withViewname(viewnameOfStart).build(); }/* w w w .j av a 2 s. c o m*/ try { initializeForm(form, id, auth, false); Pair<PageSet, ResultSet> pair = search(form); return withViewname(viewnameOfStart).addObject(pair.getLeft()).addObject(pair.getRight()).build(); } catch (BadSqlGrammarException ex) { LogicalErrorUtil.reject(binding, LogicError.BadSqlGrammer, Util.getRootCause(ex).getMessage()); return withViewname(viewnameOfStart).build(); } }