List of usage examples for org.apache.commons.lang3.tuple Pair of
public static <L, R> Pair<L, R> of(final L left, final R right)
Obtains an immutable pair of from two objects inferring the generic types.
This factory allows the pair to be created using inference to obtain the generic types.
From source file:com.videaps.cube.solving.scanning.InitialiseCubeValuesDelegate.java
private Collection<Pair<String, String>> createFaceOrder() { Collection<Pair<String, String>> faceOrderList = new ArrayList<Pair<String, String>>(); faceOrderList.add(Pair.of("U", "F")); faceOrderList.add(Pair.of("F", "D")); faceOrderList.add(Pair.of("D", "L")); faceOrderList.add(Pair.of("L", "R")); faceOrderList.add(Pair.of("R", "B")); faceOrderList.add(Pair.of("B", "U")); return faceOrderList; }
From source file:de.codecentric.batch.metrics.BatchMetricsImpl.java
@Override public void increment(String metricName, Long value) { if (TransactionSynchronizationManager.isSynchronizationActive()) { initializeMetricContainerAndRegisterTransactionSynchronizationIfNecessary(); metricContainer.get().metrics.add(Pair.of(metricName, value)); } else {//from w w w .j a v a2 s .co m incrementNonTransactional(metricName, value); } }
From source file:edu.umd.umiacs.clip.tools.math.CorrelationUtils.java
private static Pair<double[], double[]> sort(final double[] x, final double[] y) { List<Pair<Double, Double>> list = range(0, x.length).boxed().map(i -> Pair.of(x[i], y[i])) .sorted(comparing(Pair::getLeft, reverseOrder())).collect(toList()); double[] xSorted = list.stream().mapToDouble(Pair::getLeft).toArray(); double[] ySorted = list.stream().mapToDouble(Pair::getRight).toArray(); return Pair.of(xSorted, ySorted); }
From source file:com.github.steveash.jg2p.util.CartesianProductIterableTest.java
@SuppressWarnings("unchecked") @Test/*from w ww. j a v a 2 s . c o m*/ public void testIteratorFour() { assertThat(CartesianProductIterable.of(limit(source, 4)), contains(Pair.of("A", "B"), Pair.of("A", "C"), Pair.of("A", "D"), Pair.of("B", "C"), Pair.of("B", "D"), Pair.of("C", "D"))); }
From source file:com.snaplogic.snaps.lunex.RequestProcessor.java
public String execute(RequestBuilder rBuilder) throws MalformedURLException, IOException { try {/* ww w . j a v a2 s . c o m*/ URL api_url = new URL(rBuilder.getURL()); HttpURLConnection httpUrlConnection = (HttpURLConnection) api_url.openConnection(); httpUrlConnection.setRequestMethod(rBuilder.getMethod().toString()); httpUrlConnection.setDoInput(true); httpUrlConnection.setDoOutput(true); if (rBuilder.getSnapType() != LunexSnaps.Read) { rBuilder.getHeaders().add(Pair.of(CONTENT_LENGTH, rBuilder.getRequestBodyLenght())); } for (Pair<String, String> header : rBuilder.getHeaders()) { if (!StringUtils.isEmpty(header.getKey()) && !StringUtils.isEmpty(header.getValue())) { httpUrlConnection.setRequestProperty(header.getKey(), header.getValue()); } } log.debug(String.format(LUNEX_HTTP_INFO, rBuilder.getSnapType(), rBuilder.getURL(), httpUrlConnection.getRequestProperties().toString())); if (rBuilder.getSnapType() != LunexSnaps.Read) { String paramsJson = null; if (!StringUtils.isEmpty(paramsJson = rBuilder.getRequestBody())) { DataOutputStream cgiInput = new DataOutputStream(httpUrlConnection.getOutputStream()); log.debug(String.format(LUNEX_HTTP_REQ_INFO, paramsJson)); cgiInput.writeBytes(paramsJson); cgiInput.flush(); IOUtils.closeQuietly(cgiInput); } } List<String> input = null; StringBuilder response = new StringBuilder(); try (InputStream iStream = httpUrlConnection.getInputStream()) { input = IOUtils.readLines(iStream); } catch (IOException ioe) { log.warn(String.format(INPUT_STREAM_ERROR, ioe.getMessage())); try (InputStream eStream = httpUrlConnection.getErrorStream()) { if (eStream != null) { input = IOUtils.readLines(eStream); } else { response.append(String.format(INPUT_STREAM_ERROR, ioe.getMessage())); } } catch (IOException ioe1) { log.warn(String.format(INPUT_STREAM_ERROR, ioe1.getMessage())); } } statusCode = httpUrlConnection.getResponseCode(); log.debug(String.format(HTTP_STATUS, statusCode)); if (input != null && !input.isEmpty()) { for (String line : input) { response.append(line); } } return formatResponse(response, rBuilder); } catch (MalformedURLException me) { log.error(me.getMessage(), me); throw me; } catch (IOException ioe) { log.error(ioe.getMessage(), ioe); throw ioe; } catch (Exception ex) { log.error(ex.getMessage(), ex); throw ex; } }
From source file:com.github.blindpirate.gogradle.util.MapUtils.java
@SuppressWarnings("unchecked") public static <K, V> Map<K, V> asMapWithoutNull(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) { return asMapWithoutNull(new Pair[] { Pair.of(k1, v1), Pair.of(k2, v2), Pair.of(k3, v3), Pair.of(k4, v4) }); }
From source file:de.hasait.clap.impl.CLAPParseContext.java
public void addKeyword(final CLAPKeywordNode pKeywordNode) { _nodeContextMap.add(Pair.of(pKeywordNode, null)); }
From source file:gobblin.ingestion.google.webmaster.UrlTrie.java
private Pair<String, UrlTrieNode> getPrefixAndDefaultRoot(String rootPage) { if (rootPage == null || rootPage.isEmpty()) { return Pair.of(null, new UrlTrieNode(null)); } else {/*from w w w . j av a 2s. co m*/ String prefix = rootPage.substring(0, rootPage.length() - 1); Character lastChar = rootPage.charAt(rootPage.length() - 1); return Pair.of(prefix, new UrlTrieNode(lastChar)); } }
From source file:com.vmware.identity.openidconnect.server.SlidingWindowMap.java
public void add(K key, V value) { Validate.notNull(key, "key"); Validate.notNull(value, "value"); if (this.map.containsKey(key)) { throw new IllegalArgumentException("specified key is already in the map: " + key.toString()); }//w w w.jav a2 s . com Date now = this.timeProvider.getCurrentTime(); cleanUp(now); this.map.put(key, Pair.of(value, now)); }
From source file:edu.umd.umiacs.clip.tools.scor.BM25Scorer.java
@Override public Object getProcessedQuery(String query) { return tf(query).entrySet().stream() .collect(toMap(Entry::getKey, entry -> Pair.of(entry.getValue(), idf(df(entry.getKey()))))); }