Example usage for org.apache.commons.lang3.tuple ImmutablePair ImmutablePair

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

Introduction

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

Prototype

public ImmutablePair(final L left, final R right) 

Source Link

Document

Create a new pair instance.

Usage

From source file:com.microsoft.tooling.msservices.helpers.ServiceCodeReferenceHelper.java

public void fillMobileServiceResource(String activityName, String appUrl, String appKey, Object module)
        throws IOException {
    DefaultLoader.getIdeHelper().replaceInFile(module,
            new ImmutablePair<String, String>(">$APPURL_" + activityName + "<", ">" + appUrl + "<"),
            new ImmutablePair<String, String>(">$APPKEY_" + activityName + "<", ">" + appKey + "<"));
}

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 an element that is missing the required content path
 *//*from w  w  w. ja  va  2s  .com*/
@Test(expected = IllegalArgumentException.class)
public void testConstructor_withElementMissingContentPath() throws Exception {
    List<Pair<JsonContentReference, Serializable>> values = new ArrayList<>();
    values.add(new ImmutablePair<JsonContentReference, Serializable>(null, "test"));
    new JsonStaticContentInsertion(values);
}

From source file:eu.stratosphere.pact.runtime.cache.FileCache.java

/**
 * If the file doesn't exists locally, it will copy the file to the temp directory.
 *///from   w  w  w.ja va 2 s.co  m
public FutureTask<Path> createTmpFile(String name, String filePath, JobID jobID) {

    synchronized (count) {
        Pair<JobID, String> key = new ImmutablePair(jobID, name);
        if (count.containsKey(key)) {
            count.put(key, count.get(key) + 1);
        } else {
            count.put(key, 1);
        }
    }
    CopyProcess cp = new CopyProcess(name, filePath, jobID);
    FutureTask<Path> copyTask = new FutureTask<Path>(cp);
    executorService.submit(copyTask);
    return copyTask;
}

From source file:com.precioustech.fxtrading.marketdata.historic.MovingAverageCalculationService.java

public ImmutablePair<Double, Double> calculateSMAandWMAasPair(TradeableInstrument<T> instrument, DateTime from,
        DateTime to, CandleStickGranularity granularity) {
    List<CandleStick<T>> candles = this.historicMarketDataProvider.getCandleSticks(instrument, granularity,
            from, to);//from  w ww  . jav a  2s.  c o m
    return new ImmutablePair<Double, Double>(calculateSMA(candles), calculateWMA(candles));
}

From source file:edu.umd.cs.hcil.twitterreplay.ProducerTask.java

public void run() {
    System.out.println("Running with Current Time: " + mDateFormat.format(mCurrentTime));

    try {/*from w  ww  .jav a2  s.  c  o m*/
        // Find all tweets in the current interval
        List<String> messages = new ArrayList<String>();

        if (mNextItem == null || mNextItem.getLeft().compareTo(mCurrentTime) == 0) {

            System.out.println("Checking for more messages...");

            if (mNextItem != null) {
                messages.add(mNextItem.getRight());
            }

            for (String tweetJson : mInputReader) {
                try {
                    Date tweetTime = DateParser.getDateFromJson(tweetJson);

                    if (tweetTime.compareTo(mCurrentTime) < 0) {
                        System.err.println("Out of order tweet:");
                        System.err.println(tweetJson);

                        continue;
                        //                            throw new Error("Encountered Out-of-Order Tweet: " + tweetJson);
                    }

                    // Is this tweet the same as or AFTER the current time?
                    if (tweetTime.compareTo(mCurrentTime) == 0) {
                        messages.add(tweetJson);
                    } else {
                        mNextItem = new ImmutablePair<Date, String>(tweetTime, tweetJson);

                        break;
                    }
                } catch (JSONException ex) {
                    //                    LOGGER.log(Level.INFO, "JSON Exception: {0}", ex);
                    //                    LOGGER.log(Level.INFO, "Tweet JSON: {0}", tweetJson);
                } catch (ParseException ex) {
                    LOGGER.log(Level.SEVERE, "Parse Exception: {0}", ex);
                    LOGGER.log(Level.SEVERE, "Tweet JSON: {0}", tweetJson);
                }
            }
        } else {
            LOGGER.log(Level.INFO, "No messages during time: {0}", mDateFormat.format(mCurrentTime));
        }

        // Publish the messages for this interval to Kafka
        System.out.println("Message Count: " + messages.size());
        //        for ( String msg : messages ) {
        //            System.out.println(msg);
        //        }
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Unknown Exception: {0}", e);
    }

    mCurrentTime = mNextTime;
    mCalendar.add(mIntervalUnit, mInterval);
    mNextTime = mCalendar.getTime();
}

From source file:alluxio.web.WebInterfaceConfigurationServlet.java

private SortedSet<Pair<String, String>> getSortedProperties() {
    TreeSet<Pair<String, String>> rtn = new TreeSet<>();
    for (Map.Entry<String, String> entry : Configuration.toMap().entrySet()) {
        String key = entry.getKey();
        if (key.startsWith(ALLUXIO_CONF_PREFIX) && !ALLUXIO_CONF_EXCLUDES.contains(key)) {
            rtn.add(new ImmutablePair<>(key, Configuration.get(PropertyKey.fromString(key))));
        }/*  w  w  w  .j  ava  2  s .co m*/
    }
    return rtn;
}

From source file:com.javiermoreno.springboot.mvc.users.UserManagementServiceImpl.java

@Override
@Transactional//  w w w  .  j  av  a2 s  .  c o m
public Pair<List<DailyUser>, Long> retrieveAllUsers(@Min(0) int pageNumber, int amount,
        Sort.Direction direction, String sortingProperty) {
    PageRequest pr;
    if (direction != null && sortingProperty != null) {
        pr = new PageRequest(pageNumber, amount, direction, sortingProperty);
    } else {
        pr = new PageRequest(pageNumber, amount);
    }
    Page page = userRepository.findAll(pr);
    return new ImmutablePair(Lists.newArrayList(page.iterator()), page.getTotalElements());
}

From source file:io.pravega.controller.mocks.MockStreamTransactionMetadataTasks.java

@Override
@Synchronized/*from  w  w w .j av  a  2s  . co m*/
public CompletableFuture<Pair<VersionedTransactionData, List<Segment>>> createTxn(final String scope,
        final String stream, final long lease, final long maxExecutionTime, final long scaleGracePeriod,
        final OperationContext contextOpt) {
    final OperationContext context = contextOpt == null ? streamMetadataStore.createContext(scope, stream)
            : contextOpt;
    final UUID txnId = UUID.randomUUID();
    return streamMetadataStore.createTransaction(scope, stream, txnId, lease, maxExecutionTime,
            scaleGracePeriod, context, executor).thenCompose(txData -> {
                log.info("Created transaction {} with version {}", txData.getId(), txData.getVersion());
                return streamMetadataStore.getActiveSegments(scope, stream, context, executor)
                        .thenApply(segmentList -> new ImmutablePair<>(txData, segmentList));
            });
}

From source file:io.knotx.assembler.FragmentAssemblerTest.java

@Test
@KnotxConfiguration("test.unwrap.io.knotx.FragmentAssembler.json")
public void callAssemblerWithEmptySnippet_expectNoContentStatus(TestContext context) throws Exception {
    callAssemblerWithAssertions(context,
            Collections.singletonList(new ImmutablePair<>(Collections.singletonList(RAW), StringUtils.SPACE)),
            knotContext -> context.assertEquals(HttpResponseStatus.NO_CONTENT.code(),
                    knotContext.getClientResponse().getStatusCode()));
}

From source file:com.yahoo.bard.webservice.druid.model.aggregation.Aggregation.java

/**
 * Splits an Aggregation for 2-pass aggregation into an inner &amp; outer Aggregation. The outer aggregation
 * fieldName will reference the inner aggregation name. The inner aggregation is unmodified.
 *
 * @return A pair where pair.left is the outer aggregation and pair.right is the inner.
 *//*w w w . ja  v  a  2s. c  o  m*/
public Pair<Aggregation, Aggregation> nest() {
    String nestingName = this.name;
    Aggregation outer = this.withFieldName(nestingName);
    Aggregation inner = this.withName(nestingName);
    return new ImmutablePair<>(outer, inner);
}