Example usage for org.apache.commons.lang3.tuple Pair of

List of usage examples for org.apache.commons.lang3.tuple Pair of

Introduction

In this page you can find the example usage for org.apache.commons.lang3.tuple Pair of.

Prototype

public static <L, R> Pair<L, R> of(final L left, final R right) 

Source Link

Document

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.

Usage

From source file:com.coveo.spillway.storage.LimitUsageStorage.java

/**
 * Increments the specified limit by the cost and returns the current count.
 *
 * @param request An {@link AddAndGetRequest} that wraps all necessary information to perform the increment
 * @return A Pair of the limit and its current count
 */// www. ja  va 2 s  .  co  m
default Pair<LimitKey, Integer> addAndGet(AddAndGetRequest request) {
    Map.Entry<LimitKey, Integer> value = addAndGet(Arrays.asList(request)).entrySet().iterator().next();
    return Pair.of(value.getKey(), value.getValue());
}

From source file:com.hortonworks.streamline.streams.notification.service.NotificationQueueHandler.java

/**
 * Attempt re-delivery of a previously enqueued notification.
 *
 * @param notificationId id of a previously submitted notification.
 *//*from w  w w.  java  2  s. c om*/
public void resubmit(String notificationId) {
    Pair<NotificationQueueTask, Future<?>> taskStatus = taskMap.get(notificationId);
    if (taskStatus == null) {
        throw new NotificationServiceException(
                "Could not find a previously enqueued task" + " for notification id " + notificationId);
    } else if (!taskStatus.getValue().isDone()) {
        throw new NotificationServiceException(
                "Previously enqueued task" + " for notification id " + notificationId + " is not done");

    }
    Future<?> future = executorService.submit(taskStatus.getKey());
    taskMap.put(notificationId, Pair.of(taskStatus.getKey(), future));
}

From source file:edu.wpi.checksims.util.PairGeneratorTest.java

@Test
public void TestGenerateFromFourElementSet() {
    Set<Submission> submissions = setFromElements(a, b, c, d);
    Set<Pair<Submission, Submission>> expected = setFromElements(Pair.of(a, b), Pair.of(a, c), Pair.of(a, d),
            Pair.of(b, c), Pair.of(b, d), Pair.of(c, d));
    Set<Pair<Submission, Submission>> results = PairGenerator.generatePairs(submissions);

    checkPairsAreInSet(results, expected);
}

From source file:cn.lambdalib.util.client.font.Fragmentor.java

public Pair<TokenType, String> next() {
    if (index == str.length()) {
        return Pair.of(TokenType.NULL, null);
    } else {/*from ww w. j av a 2 s  . c  o  m*/
        TokenType init = getType(str.charAt(index));
        int lindex = index;
        for (++index; index < str.length(); ++index) {
            TokenType type = getType(str.charAt(index));
            if (init != TokenType.CJKV && init != type && type != TokenType.PUNCT)
                break;
        }
        return Pair.of(init, str.substring(lindex, index));
    }
}

From source file:com.github.blindpirate.gogradle.task.go.test.PlainGoTestResultExtractor.java

private List<Pair<Integer, String>> extractStartIndiceAndTestMethodNames(List<String> stdout) {
    List<Pair<Integer, String>> ret = new ArrayList<>();

    for (int i = 0; i < stdout.size(); ++i) {
        Optional<String> testName = getRootTestNameFromLine(stdout.get(i));
        if (testName.isPresent()) {
            ret.add(Pair.of(i, testName.get()));
        }//from w  w w .  ja  v a  2  s. c o m
    }
    return ret;
}

From source file:net.lldp.checksims.algorithm.AlgorithmRunnerTest.java

@Test
public void TestRunAlgorithmNullAlgorithm() throws ChecksimsException {
    expectedEx.expect(NullPointerException.class);

    AlgorithmRunner.runAlgorithm(singleton(Pair.of(a, b)), null, logger);
}

From source file:enumj.EnumerableTest.java

@Test
public void testOf_Iterable() {
    System.out.println("of");
    EnumerableGenerator.generatorPairs().limit(100)
            .map(p -> Pair.of(p.getLeft().ofIterableEnumerable(), p.getRight().ofIterableEnumerable()))
            .forEach(p -> assertTrue(p.getLeft().elementsEqual(p.getRight())));
}

From source file:com.qq.tars.service.admin.AdminService.java

public Pair<Integer, String> doCommand(String application, String serverName, String nodeName, String command)
        throws TARSRequestException {
    Holder<String> holder = new Holder<>();
    int ret = getAdminRegPrx().notifyServer(application, serverName, nodeName, command, holder);
    if (ret == 0) {
        return Pair.of(ret, holder.getValue());
    } else {//  ww  w.j a  va  2s .c om
        throw new TARSRequestException(ret);
    }
}

From source file:edu.wpi.checksims.algorithm.AlgorithmRunnerTest.java

@Test
public void TestRunAlgorithmThreePairs() {
    Set<Pair<Submission, Submission>> submissions = setFromElements(Pair.of(a, b), Pair.of(a, c),
            Pair.of(b, c));//from w  w  w  . ja v a2  s  .  com
    Collection<AlgorithmResults> results = AlgorithmRunner.runAlgorithm(submissions, detectNothing);

    AlgorithmUtils.checkResultsContainsPairs(results, submissions);
}

From source file:com.addthis.hydra.job.HostFailState.java

/**
 * Retrieve the next host to fail/*from  www  .j  av  a2  s.c  om*/
 *
 * @return The uuid of the next host to fail, and whether the file system is dead. If the queue is empty, return null.
 */
public Pair<String, FailState> nextHostToFail() {
    synchronized (hostsToFailByType) {
        String hostUuid = findFirstHost(failFsDead, false);
        if (hostUuid != null) {
            return Pair.of(hostUuid, FailState.FAILING_FS_DEAD);
        }
        hostUuid = findFirstHost(fsFull, true);
        if (hostUuid != null) {
            return Pair.of(hostUuid, FailState.DISK_FULL);
        }
        hostUuid = findFirstHost(failFsOkay, true);
        if (hostUuid != null) {
            return Pair.of(hostUuid, FailState.FAILING_FS_OKAY);
        }
        return null;
    }
}