List of usage examples for org.apache.commons.lang3.tuple ImmutablePair ImmutablePair
public ImmutablePair(final L left, final R right)
From source file:net.mindengine.galen.specs.reader.page.StateDoingRule.java
@Override public void process(VarsContext varsContext, String line, Place place) throws IOException { if (!line.trim().isEmpty()) { if (firstIndentation < 0) { firstIndentation = amountOfSpaces(line); } else {// w w w . j av a 2 s. c o m if (amountOfSpaces(line) < firstIndentation) { throw new SyntaxException("Incorrect indentation inside rule"); } } lines.add(new ImmutablePair<String, Place>(line.substring(firstIndentation), place)); } }
From source file:eu.bittrade.libs.steemj.BaseIT.java
/** * Call this method in case the tests should be fired against the TestNet * endpoint instead of using the default HTTPS endpoint. * /* w w w .ja va 2 s . com*/ * @throws URISyntaxException * If the URL is wrong. */ public static void configureTestNetHttpEndpoint() throws URISyntaxException { ArrayList<Pair<URI, Boolean>> endpoints = new ArrayList<>(); ImmutablePair<URI, Boolean> webSocketEndpoint; webSocketEndpoint = new ImmutablePair<>(new URI("https://testnet.steem.vc"), true); endpoints.add(webSocketEndpoint); config.setEndpointURIs(endpoints); }
From source file:com.yahoo.bard.webservice.druid.model.aggregation.SketchCountAggregation.java
@Override public Pair<Aggregation, Aggregation> nest() { String nestingFieldName = getName(); // In order to maintain the correct meaning of the sketch count, the sketch merge must nest at all lower levels SketchMergeAggregation innerMerge = new SketchMergeAggregation(nestingFieldName, getFieldName(), getSize()); SketchCountAggregation outerCount = this.withFieldName(nestingFieldName); return new ImmutablePair<>(outerCount, innerMerge); }
From source file:fr.cvlaminck.merging.impl.strategy.ImmutableObjectMergingStrategyTest.java
@Test public void testConstructorWithVariableArgs() { final ImmutableObjectMergingStrategy immutable = new ImmutableObjectMergingStrategy(Object.class, new ImmutablePair<>("A", "A"), new ImmutablePair<>(Object.class, "B")); assertEquals(Object.class, immutable.getObject()); assertEquals("A", immutable.getSpecificStrategyForField("A")); assertEquals("B", immutable.getDefaultStrategyForType(Object.class)); }
From source file:biz.karms.sinkit.ejb.util.CIDRUtils.java
public static ImmutablePair<String, String> getStartEndAddresses(final String cidr) throws UnknownHostException { //TODO: This is silly. Refactor CIDRUtils so as to accept actual IPs as well as subnets. //TODO: Validate the thing before processing. Guava? final String fixedCIDR; if (!cidr.contains("/")) { //IPv6? Hmmm... if (cidr.contains(":")) { fixedCIDR = cidr + "/128"; } else {//from w w w .j av a 2 s . c om fixedCIDR = cidr + "/32"; } } else { fixedCIDR = cidr; } final int index = fixedCIDR.indexOf("/"); final InetAddress inetAddress = InetAddress.getByName(fixedCIDR.substring(0, index)); final int prefixLength = Integer.parseInt(fixedCIDR.substring(index + 1)); final ByteBuffer maskBuffer; if (inetAddress.getAddress().length == 4) { maskBuffer = ByteBuffer.allocate(4).putInt(-1); } else { maskBuffer = ByteBuffer.allocate(16).putLong(-1L).putLong(-1L); } final BigInteger mask = (new BigInteger(1, maskBuffer.array())).not().shiftRight(prefixLength); final ByteBuffer buffer = ByteBuffer.wrap(inetAddress.getAddress()); final BigInteger ipVal = new BigInteger(1, buffer.array()); final BigInteger startIp = ipVal.and(mask); final BigInteger endIp = startIp.add(mask.not()); return new ImmutablePair<>(String.format("%040d", startIp), String.format("%040d", endIp)); }
From source file:com.acmutv.ontoqa.core.parser.state.ConflictElement.java
/** * Adds conflict element for substitution. * @param candidate the SLTAG candidate. * @param prevIdx the previous lexical entry index. *//*from w w w.ja v a 2 s . c om*/ public void addAdjunction(Sltag candidate, Integer prevIdx) { this.getAdjunctions().add(new ImmutablePair<>(candidate, prevIdx)); }
From source file:fr.lirmm.graphik.util.MathUtils.java
/** * Comput the cartesian product of the specified set with itself. * input: { A, B, C }/*from ww w .java 2 s.c o m*/ * output : { (A,A), (A,B), (B,B) } * @param set * @return */ public static <T> Iterable<Pair<T, T>> selfCartesianProduct(Iterable<T> set) { Collection<Pair<T, T>> pairs = new LinkedList<Pair<T, T>>(); Iterator<T> it = set.iterator(); while (it.hasNext()) { T a = it.next(); for (T b : set) { pairs.add(new ImmutablePair<T, T>(a, b)); } if (it.hasNext()) { // FIXfor singleton implementation it.remove(); } } return pairs; }
From source file:fr.cnrs.sharp.reasoning.Unification.java
public static List<Pair<RDFNode, RDFNode>> selectSubstitutions(Model m) { // UNIFICATION : 1. finding substitution of existential variables String querySubstitutionFinding = "SELECT distinct ?blank_node ?node WHERE { \n" + " { \n" + " ?i ?p ?blank_node .\n" + " FILTER (isBlank(?blank_node)) .\n" + "\n" + " ?i ?p ?node .\n" + " FILTER ((?node != ?blank_node) && (! isBlank(?node))) .\n" + " } UNION { \n" + " ?blank_node ?q ?j .\n" + " FILTER (isBlank(?blank_node)) .\n" + "\n" + " ?node ?q ?j .\n" + " FILTER ((?node != ?blank_node) && (! isBlank(?node))) .\n" + " }\n" + "}"; Query query = QueryFactory.create(querySubstitutionFinding); QueryExecution qexec = QueryExecutionFactory.create(query, m); ResultSet results = qexec.execSelect(); List<Pair<RDFNode, RDFNode>> toBeMerged = new ArrayList<>(); while (results.hasNext()) { QuerySolution qs = results.nextSolution(); RDFNode blankN = qs.get("?blank_node"); RDFNode node = qs.get("?node"); toBeMerged.add(new ImmutablePair(blankN, node)); }//from w w w.ja va2 s . co m // ResultSetFormatter.out(System.out, results, query); qexec.close(); return toBeMerged; }
From source file:com.ex.data.PlintDirection.java
/** * Create one of Plint Direction. Left and right pairs will be connected. * @param connectorIdLeft Unique identifier of left Connector * @param plintNumberLeft Plint Number in the left Connector * @param connectorIdRight Unique identifier of right Connector * @param plintNumberRight Plint Number in the right Connector *///w w w . j a v a 2 s .c o m public PlintDirection(long connectorIdLeft, int plintNumberLeft, long connectorIdRight, int plintNumberRight) { super(new ImmutablePair<Long, Integer>(connectorIdLeft, plintNumberLeft), new ImmutablePair<Long, Integer>(connectorIdRight, plintNumberRight)); }
From source file:com.ottogroup.bi.streaming.operator.json.insert.JsonStaticContentInsertionTest.java
/** * Test case for {@link JsonStaticContentInsertion#JsonStaticContentInsertion(java.util.List)} being provided a * configuration which holds a "null" element *//* w w w. j a v a2s . c o m*/ @Test(expected = IllegalArgumentException.class) public void testConstructor_withNullListElement() throws Exception { List<Pair<JsonContentReference, Serializable>> values = new ArrayList<>(); values.add(new ImmutablePair<JsonContentReference, Serializable>( new JsonContentReference(new String[] { "valid" }, JsonContentType.STRING), "test")); values.add(null); new JsonStaticContentInsertion(values); }