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.spotify.heroic.metric.TagValues.java
public Iterator<Map.Entry<String, String>> iterator() { final Iterator<String> values = this.values.iterator(); return new Iterator<Map.Entry<String, String>>() { @Override//ww w . java 2 s . co m public boolean hasNext() { return values.hasNext(); } @Override public Map.Entry<String, String> next() { return Pair.of(key, values.next()); } }; }
From source file:de.ellpeck.actuallyadditions.mod.items.ItemFillingWand.java
private static Pair<IBlockState, String> loadData(ItemStack stack) { if (stack.hasTagCompound()) return Pair.of(Block.getStateById(stack.getTagCompound().getInteger("state")), stack.getTagCompound().getString("name")); return null;//from w w w. jav a 2s . com }
From source file:edu.umd.umiacs.clip.tools.scor.IndriBM25Scorer.java
@Override public Object getProcessedQuery(String query) { String[] tokens = query.replace("(", "( ").replace(")", " ) ").replaceAll("\\s+\\(", "(").trim() .split("\\s+"); List<Pair<List<Pair<String, Float>>, Float>> processed = new ArrayList<>(); for (int i = 0; i < tokens.length; i++) { String token = tokens[i]; if (token.startsWith("#syn(") || token.startsWith("#wsyn(")) { float df = 0; boolean isWeighted = token.startsWith("#wsyn("); List<Pair<String, Float>> list = new ArrayList<>(); for (i++; i < tokens.length; i++) { token = tokens[i];/* w w w .j a v a 2 s . c o m*/ if (token.equals(")")) { break; } float weight = 1f; if (isWeighted) { weight = new Float(tokens[i++]); token = tokens[i]; } list.add(Pair.of(token, weight)); df += weight * df(token); } processed.add(Pair.of(list, idf(df))); } else { processed.add(Pair.of(asList(Pair.of(token, 1f)), idf(df(token)))); } } return processed; }
From source file:alfio.util.PreReservedTicketDistributor.java
@Override public BiConsumer<List<Pair<Integer, TicketCategoryStatisticView>>, Pair<Integer, TicketCategoryStatisticView>> accumulator() { return (accumulator, candidate) -> { int requested = requestedTickets.get(); if (requested > 0) { int capacity = Math.min(requested, candidate.getKey()); accumulator.add(Pair.of(capacity, candidate.getValue())); requestedTickets.addAndGet(-capacity); }//from w w w . ja v a2s .c om }; }
From source file:net.lldp.checksims.algorithm.preprocessor.CommonCodeLineRemovalPreprocessor.java
private static <T extends Percentable> AlgorithmResults getResults(Submission rf, Submission com, SimilarityDetector<T> a) throws TokenTypeMismatchException, InternalAlgorithmError { T rft = a.getPercentableCalculator().fromSubmission(rf); T comt = a.getPercentableCalculator().fromSubmission(com); return a.detectSimilarity(Pair.of(rf, com), rft, comt); }
From source file:de.hasait.clap.impl.CLAPParseContext.java
public <T> void addDecision(final AbstractCLAPDecision pDecisionNode, final AbstractCLAPNode pBranchNode) { _nodeContextMap.add(Pair.of(pDecisionNode, pBranchNode)); }
From source file:alfio.manager.location.DefaultLocationManager.java
@Override @Cacheable// w w w .ja v a 2 s . c o m public Pair<String, String> geocode(String address) { return Optional.ofNullable(GeocodingApi.geocode(getApiContext(), address).awaitIgnoreError()) .filter(r -> r.length > 0).map(r -> r[0].geometry.location) .map(l -> Pair.of(Double.toString(l.lat), Double.toString(l.lng))) .orElseThrow(() -> new LocationNotFound("No location found for address " + address)); }
From source file:fr.landel.utils.commons.StringUtilsPerf.java
/** * Test method for/*from w ww .ja v a 2s . c o m*/ * {@link StringUtils#injectKeys(CharSequence, java.util.Map.Entry...)}. */ @Benchmark public void testInjectKeys() { StringUtils.injectKeys("I'll go to {where} this {when}", Pair.of("where", "beach"), Pair.of("when", "afternoon")); StringUtils.injectKeys("I'll go to {where} this {when} {{when}}", Pair.of("where", "beach"), Pair.of("when", "afternoon")); StringUtils.injectKeys("I'll go to {where} this {when}", MapUtils2.newHashMap(Pair.of("where", "beach"), Pair.of("when", "afternoon"))); StringUtils.injectKeys("I'll go to {where}", Collections.singletonMap("where", "beach")); }
From source file:de.tntinteractive.portalsammler.engine.MapReader.java
public Pair<String, Map<String, String>> readNext() throws IOException { final String id = this.reader.readLine(); if (id == null) { return null; }//from ww w . ja va2 s.c om final Map<String, String> map = new LinkedHashMap<String, String>(); while (true) { final String firstLine = this.reader.readLine(); if (firstLine.equals(".")) { break; } final String secondLine = this.reader.readLine(); map.put(lineToValue(firstLine), lineToValue(secondLine)); } return Pair.of(id, map); }
From source file:com.yahoo.elide.parsers.state.RecordTerminalState.java
@Override public Supplier<Pair<Integer, JsonNode>> handleGet(StateContext state) { ObjectMapper mapper = state.getRequestScope().getMapper().getObjectMapper(); return () -> Pair.of(HttpStatus.SC_OK, getResponseBody(record, state.getRequestScope(), mapper)); }