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

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

Introduction

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

Prototype

public abstract L getLeft();

Source Link

Document

Gets the left element from this pair.

When treated as a key-value pair, this is the key.

Usage

From source file:com.streamsets.pipeline.lib.jdbc.multithread.cache.SQLServerCTContextLoader.java

@Override
public TableReadContext load(TableRuntimeContext tableRuntimeContext) throws Exception {
    TableContext tableContext = tableRuntimeContext.getSourceTableContext();

    final Map<String, String> offset = OffsetQueryUtil
            .getColumnsToOffsetMapFromOffsetFormat(offsets.get(tableRuntimeContext.getOffsetKey()));

    String query = MSQueryUtil.buildQuery(offset, fetchSize, tableContext.getQualifiedName(),
            tableContext.getOffsetColumns(), tableContext.getOffsetColumnToStartOffset(), includeJoin,
            tableContext.getOffset());// w ww . j a  v  a 2  s.  c  o m

    Pair<String, List<Pair<Integer, String>>> queryAndParamValToSet = Pair.of(query, new ArrayList<>());

    Connection connection = connectionManager.getConnection();

    TableReadContext tableReadContext = new TableReadContext(connection, queryAndParamValToSet.getLeft(),
            queryAndParamValToSet.getRight(), fetchSize);

    return tableReadContext;
}

From source file:controllers.admin.AttachmentsController.java

/**
 * The attachments management main page. Displays a table with the list of all attachments across the application.
 *///from   w  w w  .ja  va2s. c  om
public Result index() {
    String uid = getUserSessionManagerPlugin().getUserSessionId(ctx());
    FilterConfig<AttachmentManagementListView> filterConfig = this.getTableProvider().get().attachmentManagement
            .getResetedFilterConfig().getCurrent(uid, request());

    Pair<Table<AttachmentManagementListView>, Pagination<Attachment>> t = getTable(filterConfig);

    return ok(views.html.admin.attachments.attachments_index.render(t.getLeft(), t.getRight(), filterConfig));
}

From source file:eu.stratosphere.nephele.streaming.taskmanager.chaining.TaskChainer.java

/**
 * Searches for chains that continually use up more than one CPU core and
 * splits all of them up into two chains in the background.
 *//* w  w w. j  ava2s.c  o  m*/
private void splitChainsIfNecessary() {

    int currChainIndex = 0;
    while (currChainIndex < this.chains.size()) {
        TaskChain chain = this.chains.get(currChainIndex);

        if (chain.hasCPUUtilizationMeasurements() && chain.getCPUUtilization() > 99
                && chain.getNumberOfChainedTasks() > 1) {

            Pair<TaskChain, TaskChain> splitResult = splitChain(chain);
            this.chains.set(currChainIndex, splitResult.getLeft());
            this.chains.add(currChainIndex + 1, splitResult.getRight());
            currChainIndex = currChainIndex + 2;
        } else {
            currChainIndex++;
        }
    }
}

From source file:net.mindengine.blogix.tests.acceptance.BlogixServerAccTest.java

@DataProvider
public Object[][] provideSampleFileResponses() throws Exception {
    List<Pair<String, String>> checks = RequestSampleParser
            .loadRequestChecksFromFile(new File(getClass().getResource("/file-request-samples.txt").toURI()));

    Object[][] arr = new Object[checks.size()][];
    int i = -1;/*from   www  . j av  a 2s.com*/
    for (Pair<String, String> check : checks) {
        i++;
        String url = check.getLeft();
        String[] right = check.getRight().split("\\|");
        String contentType = right[0].trim();
        String filePath = right[1].trim();
        File file = null;
        if (!filePath.isEmpty()) {
            file = new File(getClass().getResource("/" + filePath).toURI());
        }
        arr[i] = new Object[] { url, contentType, file };
    }
    return arr;
}

From source file:ca.on.oicr.pde.workflows.GATKGenotypeGVCFsWorkflow.java

private <T, S> Set<T> getLeftCollection(Collection<Pair<T, S>> pairs) {
    LinkedHashSet<T> ts = new LinkedHashSet<>();
    for (Pair<T, S> p : pairs) {
        ts.add(p.getLeft());
    }//from w  w w .  jav a2s .c  o m
    return ts;
}

From source file:models.Document.java

/**
 * @return The JSON source for this document as compact JSON-LD with an
 *         extracted, external context, or null if conversion failed.
 *//*w w  w  .  j  a va 2 s . co m*/
public String getSource() {
    try {
        final Pair<URL, String> localAndPublicContextUrls = getContextUrls();
        final Map<String, Object> contextObject = (Map<String, Object>) JSONUtils
                .fromURL(localAndPublicContextUrls.getLeft());
        final Map<String, Object> compactJsonLd = (Map<String, Object>) JSONLD
                .compact(JSONUtils.fromString(source), contextObject);
        compactJsonLd.put("@context", localAndPublicContextUrls.getRight());
        final String result = JSONUtils.toString(compactJsonLd);
        return this.field.isEmpty() ? result : findField(result);
    } catch (JSONLDProcessingError | IOException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:cherry.foundation.code.CodeManagerImpl.java

@Override
public void afterPropertiesSet() {
    entryCache = CacheBuilder.from(entryCacheSpec).build(new CacheLoader<Pair<String, String>, CodeEntry>() {
        @Override/*w ww.ja  v  a2s  .c  om*/
        public CodeEntry load(Pair<String, String> key) {
            return ObjectUtils.firstNonNull(codeStore.findByValue(key.getLeft(), key.getRight()), nullEntry);
        }
    });
    listCache = CacheBuilder.from(listCacheSpec).build(new CacheLoader<String, List<CodeEntry>>() {
        @Override
        public List<CodeEntry> load(String key) {
            return codeStore.getCodeList(key);
        }
    });
}

From source file:cl.troncador.delfin.query.constraint.PrepareOrderAdapter.java

public Order[] getOrderArray(Root<T> root, CriteriaBuilder criteriaBuilder) {
    List<Order> orderList = new ArrayList<Order>();

    for (Pair<SingularAttribute<T, ?>, Direction> directionedColumn : directionedColumnList) {
        Direction direction = directionedColumn.getRight();
        SingularAttribute<T, ?> column = directionedColumn.getLeft();
        Path<?> path = root.get(column);
        Order order = null;//from w  w w  . j  ava  2 s. c  om
        switch (direction) {
        case ASC:
            order = criteriaBuilder.asc(path);
            break;
        case DES:
            order = criteriaBuilder.desc(path);
            break;
        }
        orderList.add(order);
    }
    return orderList.toArray(new Order[orderList.size()]);
}

From source file:com.act.lcms.AnimateNetCDFAroundMass.java

private List<XYZ> getSpectra(Iterator<LCMSSpectrum> spectraIt, Double time, Double tWin, Double mz,
        Double mzWin) {//ww w.j  a  v a2s  .c om
    double mzLow = mz - mzWin;
    double mzHigh = mz + mzWin;
    double timeLow = time - tWin;
    double timeHigh = time + tWin;

    List<XYZ> spectra = new ArrayList<>();

    while (spectraIt.hasNext()) {
        LCMSSpectrum timepoint = spectraIt.next();

        if (timepoint.getTimeVal() < timeLow || timepoint.getTimeVal() > timeHigh)
            continue;

        // get all (mz, intensity) at this timepoint
        for (Pair<Double, Double> mz_int : timepoint.getIntensities()) {
            double mzHere = mz_int.getLeft();
            double intensity = mz_int.getRight();

            if (mzHere < mzLow || mzHere > mzHigh)
                continue;

            spectra.add(new XYZ(timepoint.getTimeVal(), mzHere, intensity));
        }
    }

    return spectra;
}

From source file:com.romeikat.datamessie.core.base.util.LuceneQueryUtil.java

public Query getProximityQuery(final Collection<String> term1Variants, final Collection<String> term2Variants,
        final Integer slop) {
    if (term1Variants.isEmpty() || term2Variants.isEmpty()) {
        return new MatchAllDocsQuery();
    }//  www. j  a va2  s.  co m

    final BooleanQuery.Builder builder = new BooleanQuery.Builder();
    final Collection<Pair<String, String>> variantsCombinations = collectionUtil.getPairs(term1Variants,
            term2Variants);
    for (final Pair<String, String> variantsCombination : variantsCombinations) {
        final PhraseQuery.Builder builder2 = new PhraseQuery.Builder();
        builder2.add(new Term(FIELD, variantsCombination.getLeft()));
        builder2.add(new Term(FIELD, variantsCombination.getRight()));
        builder2.setSlop(slop == null ? Integer.MAX_VALUE : slop);

        builder.add(builder2.build(), BooleanClause.Occur.MUST);
    }

    return builder.build();
}