List of usage examples for org.apache.commons.lang3.tuple Pair getLeft
public abstract L getLeft();
Gets the left element from this pair.
When treated as a key-value pair, this is the key.
From source file:de.hasait.clap.impl.CLAPParseContext.java
public int getNodeCount(final AbstractCLAPNode pNode) { int result = 0; for (final Pair<? extends AbstractCLAPNode, ? extends Object> entry : _nodeContextMap) { if (entry.getLeft().equals(pNode)) { result++;//from www.j a va2 s . c o m } } return result; }
From source file:de.hasait.clap.impl.CLAPParseContext.java
public String[] getOptionArgs(final CLAPOptionNode<?> pOptionNode) { final List<String> result = new ArrayList<String>(); boolean anyFound = false; for (final Pair<? extends AbstractCLAPNode, ? extends Object> entry : _nodeContextMap) { if (entry.getLeft().equals(pOptionNode)) { result.addAll((List<String>) entry.getRight()); anyFound = true;// w w w .j a v a 2s .co m } } return anyFound ? result.toArray(new String[result.size()]) : null; }
From source file:cherry.foundation.querydsl.CustomizingConfigurationFactoryBean.java
@Override public void afterPropertiesSet() throws Exception { if (listeners != null) { for (SQLListener l : listeners) { configuration.addListener(l); }//from ww w . j a v a 2 s . c o m } if (customTypes != null) { for (Type<?> t : customTypes) { configuration.register(t); } } if (numericTypeSpecs != null) { for (String spec : numericTypeSpecs) { List<String> l = Splitter.onPattern(",").trimResults().splitToList(spec); if (l.size() != 3) { throw new IllegalArgumentException( "numericTypeSpecs must be \"{total},{decimal},{javaType}\" or \"{beginTotal}-{endTotal},{beginDecimal}-{endDecimal},{javaType}\""); } Pair<Integer, Integer> total = parsePair(l.get(0)); Pair<Integer, Integer> decimal = parsePair(l.get(1)); configuration.registerNumeric(total.getLeft(), total.getRight(), decimal.getLeft(), decimal.getRight(), Class.forName(l.get(2))); } } }
From source file:com.github.steveash.jg2p.align.Alignment.java
private List<String> getNextX(Iterator<Pair<String, String>> iter) { Pair<String, String> graphone = iter.next(); return spaceSplit.splitToList(graphone.getLeft()); }
From source file:gobblin.ingestion.google.webmaster.UrlTriePostOrderIteratorTest.java
@Test public void testTrie2TraversalWithSize2() { UrlTrie trie = getUrlTrie2(_property); UrlTriePostOrderIterator iterator = new UrlTriePostOrderIterator(trie, 2); ArrayList<String> chars = new ArrayList<>(); while (iterator.hasNext()) { Pair<String, UrlTrieNode> next = iterator.next(); chars.add(next.getLeft()); }/* ww w .ja v a 2 s . c o m*/ Assert.assertEquals(new String[] { // _property + "03", //group size 1, contains _property + "04", //group size 1, contains _property + "0", //group size 1(count is 3), equals _property + "1", //group size 1, contains _property + "25", //group size 2, contains _property + "26", //group size 1, contains _property + "2", //group size 1(count is 4), equals _property //group size 1(count is 9), equals }, chars.toArray()); }
From source file:com.github.steveash.jg2p.train.JointEncoderTrainer.java
private int collectGoodAligns(Collection<Alignment> crfExamples, PhonemeCrfModel crfModel, ProbTable goodAligns, Set<Alignment> goodExamples) { int goodAlignCount = 0; for (Alignment crfExample : crfExamples) { List<PhonemeCrfModel.TagResult> predicts = crfModel.tag(crfExample.getAllXTokensAsList(), 1); if (predicts.size() > 0) { if (predicts.get(0).isEqualTo(crfExample.getYTokens())) { // good example, let's increment all of its transitions for (Pair<String, String> graphone : crfExample) { goodAligns.addProb(graphone.getLeft(), graphone.getRight(), 1.0); }/*w w w . j a va2s. c om*/ goodAlignCount += 1; goodExamples.add(crfExample); } } } return goodAlignCount; }
From source file:de.openali.odysseus.chart.ext.base.layer.HoverIndex.java
public synchronized EditInfo findElement(final Point pos) { final com.infomatiq.jsi.Point searchPoint = new com.infomatiq.jsi.Point(pos.x, pos.y); final List<Pair<Polygon, EditInfo>> result = new ArrayList<>(1); result.add(null);//from w ww.j av a 2s . c o m final List<Pair<Polygon, EditInfo>> elements = m_elements; final TIntProcedure receiver = new TIntProcedure() { @Override public boolean execute(final int index) { final Pair<Polygon, EditInfo> element = elements.get(index); result.set(0, element); return false; } }; // REMARK: use snap distance 0, we assume that the given rectangle was already including a 'snap' m_index.nearest(searchPoint, receiver, 0f); final Pair<Polygon, EditInfo> pair = result.get(0); if (pair == null) return null; final Polygon bounds = pair.getLeft(); final com.vividsolutions.jts.geom.Point searchLocation = bounds.getFactory() .createPoint(new Coordinate(pos.x, pos.y)); if (bounds.distance(searchLocation) > 1) return null; /* Exact position was not set during creation of info..., so we set it now */ final EditInfo info = pair.getRight(); return new EditInfo(info.getLayer(), info.getHoverFigure(), info.getEditFigure(), info.getData(), info.getText(), pos); }
From source file:com.netflix.genie.web.data.services.jpa.JpaAgentConnectionPersistenceServiceImplIntegrationTest.java
@SafeVarargs private final void verifyExpectedConnections(final Pair<String, String>... expectedConnections) { Assert.assertThat(this.agentConnectionRepository.count(), Matchers.is((long) expectedConnections.length)); for (final Pair<String, String> expectedConnection : expectedConnections) { // Verify a connection exists for this job id final String jobId = expectedConnection.getLeft(); final String hostname = expectedConnection.getRight(); final Optional<String> serverOptional = agentConnectionPersistenceService .lookupAgentConnectionServer(jobId); Assert.assertTrue(serverOptional.isPresent()); Assert.assertThat(serverOptional.get(), Matchers.is(hostname)); }// w w w.jav a2 s.co m }
From source file:io.knotx.adapter.common.http.HttpClientFacade.java
private Observable<HttpClientResponse> callService(Pair<ClientRequest, ServiceMetadata> serviceData, HttpMethod method) {// ww w .j ava2 s. c o m final ClientRequest serviceRequest = serviceData.getLeft(); final ServiceMetadata serviceMetadata = serviceData.getRight(); return Observable.create(subscriber -> { HttpClientRequest httpRequest = httpClient.request(method, serviceMetadata.getPort(), serviceMetadata.getDomain(), serviceRequest.getPath()); Observable<HttpClientResponse> resp = httpRequest.toObservable(); resp.subscribe(subscriber); MultiMap filteredHeaders = getFilteredHeaders(serviceRequest.getHeaders(), serviceMetadata.getAllowedRequestHeaderPatterns()); filteredHeaders.names() .forEach(headerName -> httpRequest.putHeader(headerName, filteredHeaders.get(headerName))); if (!serviceRequest.getFormAttributes().isEmpty()) { httpRequest.end(UrlEncodedBodyBuilder.encodeBody(serviceRequest.getFormAttributes())); } else { httpRequest.end(); } }); }
From source file:eu.bittrade.libs.steemj.communication.CommunicationHandler.java
/** * Initialize a new <code>client</code> by selecting one of the configured * endpoints./*from w w w . j av a2 s.c o m*/ * * @throws SteemCommunicationException * If no {@link AbstractClient} implementation for the given * schema is available. */ public void initializeNewClient() throws SteemCommunicationException { if (client != null) { try { client.closeConnection(); } catch (IOException e) { throw new SteemCommunicationException("Could not close the current client connection.", e); } } // Get a new endpoint URI based on the number of retries. Pair<URI, Boolean> endpoint = SteemJConfig.getInstance().getNextEndpointURI(numberOfConnectionTries); if (endpoint.getLeft().getScheme().toLowerCase().matches("(http){1}[s]?")) { client = new HttpClient(); } else if (endpoint.getLeft().getScheme().toLowerCase().matches("(ws){1}[s]?")) { client = new WebsocketClient(); } else { throw new InvalidParameterException("No client implementation for the following protocol available: " + endpoint.getLeft().getScheme().toLowerCase()); } }