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

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

Introduction

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

Prototype

public static <L, M, R> Triple<L, M, R> of(final L left, final M middle, final R right) 

Source Link

Document

Obtains an immutable triple of from three objects inferring the generic types.

This factory allows the triple to be created using inference to obtain the generic types.

Usage

From source file:edu.umd.umiacs.clip.tools.math.Formatter.java

public static Triple<Double, Double, Double> format(Triple<Double, Double, Double> triple) {
    return Triple.of(format(triple.getLeft()), format(triple.getMiddle()), format(triple.getRight()));
}

From source file:fr.landel.utils.commons.function.TriSupplierTest.java

/**
 * Test method for {@link TriSupplier#get()}.
 *///from  w ww.j a  v  a2s  . c  o m
@Test
public void testGet() {
    boolean test = false;
    final String error = "error";

    final TriSupplier<String, String, String> s1 = () -> Triple.of("l", "m", "r");
    final TriSupplier<String, String, String> s2 = () -> {
        if (test) {
            return Triple.of("l", "m", "r");
        }
        throw new IllegalArgumentException(error);
    };

    try {
        assertEquals("(l,m,r)", s1.get().toString());
    } catch (FunctionException e) {
        fail("Supplier failed");
    }

    try {
        s2.get();
        fail("Supplier has to fail");
    } catch (IllegalArgumentException e) {
        assertNotNull(e);
        assertEquals(error, e.getMessage());
    }
}

From source file:fr.landel.utils.commons.function.TriSupplierThrowableTest.java

/**
 * Test method for {@link TriSupplierThrowable#get()}.
 *//*  w ww.  ja v  a  2 s .  c om*/
@Test
public void testGet() {
    boolean test = false;
    final String error = "error";

    final TriSupplierThrowable<String, String, String, IllegalArgumentException> s1 = () -> Triple.of("l", "m",
            "r");
    final TriSupplierThrowable<String, String, String, IOException> s2 = () -> {
        if (test) {
            return Triple.of("l", "m", "r");
        }
        throw new IOException(error);
    };

    try {
        assertEquals("(l,m,r)", s1.get().toString());
    } catch (FunctionException e) {
        fail("Supplier failed");
    }

    try {
        s2.get();
        fail("Supplier has to fail");
        throw new IOException(); // just for the compiler
    } catch (IOException e) {
        assertNotNull(e);
        assertEquals(error, e.getMessage());
    }
}

From source file:mtsar.processors.task.FixedNumberAllocator.java

@Override
protected List<Integer> filterTasks(Map<Integer, Integer> counts) {
    checkAnswersPerTask();//from ww  w .  j av  a2  s .co  m
    return counts.entrySet().stream().filter(entry -> entry.getValue() < answersPerTask)
            .map(entry -> Triple.of(entry.getKey(), entry.getValue(), Math.random())).sorted(INVERSE_COUNT)
            .map(Triple::getLeft).collect(Collectors.toList());
}

From source file:com.lithium.flow.shell.tunnel.CachedTunneler.java

@Override
@Nonnull/* w  w  w . ja  va  2s  . c  o m*/
public Tunnel getTunnel(@Nonnull String host, int port, @Nullable String through) throws IOException {
    try {
        return unchecked(() -> tunnels.get(Triple.of(host, port, through)));
    } catch (UncheckedException e) {
        throw e.unwrap(IOException.class);
    }
}

From source file:gobblin.ingestion.google.webmaster.UrlTriePrefixGrouper.java

@Override
public boolean hasNext() {
    if (_retVal != null) {
        return true;
    }/*from   w w w  .  j  a v  a2  s. c  o  m*/

    while (_iterator.hasNext() && _retVal == null) {
        Pair<String, UrlTrieNode> nextPair = _iterator.next();
        UrlTrieNode nextNode = nextPair.getRight();
        if (nextNode.getSize() <= _groupSize) {
            _retVal = Triple.of(nextPair.getLeft(), GoogleWebmasterFilter.FilterOperator.CONTAINS, nextNode);
            return true;
        } else if (nextNode.isExist()) {
            _retVal = Triple.of(nextPair.getLeft(), GoogleWebmasterFilter.FilterOperator.EQUALS, nextNode);
            return true;
        }
    }
    return false;
}

From source file:index.IndexManager.java

public static Triple<SolrInputDocument, Collection<String>, Collection<String>> index(Document document) {
    final SolrInputDocument index = new SolrInputDocument();
    index.setField("id", document.location());
    index.setField("time", String.valueOf(System.currentTimeMillis()));
    index.setField("title", document.title());

    final Set<String> links = document.select("a[href]").stream().map(e -> e.attr("abs:href"))
            .collect(Collectors.toSet());
    final Set<String> media = document.select("[src]").stream().map(e -> e.attr("abs:src"))
            .collect(Collectors.toSet());

    links.forEach(link -> index.addField("link", link));
    media.forEach(link -> index.addField("media", link));

    formatText(document.getElementsByTag("h1").stream()).forEach(e -> index.addField("h1", e));

    formatText(document.getElementsByTag("h2").stream()).forEach(e -> index.addField("h2", e));

    formatText(document.getElementsByTag("h3").stream()).forEach(e -> index.addField("h3", e));

    formatText(document.getElementsByTag("strong").stream()).forEach(e -> index.addField("strong", e));

    formatText(document.getElementsByTag("em").stream()).forEach(e -> index.addField("em", e));

    formatText(document.getElementsByTag("b").stream()).forEach(e -> index.addField("b", e));

    formatText(document.getElementsByTag("u").stream()).forEach(e -> index.addField("u", e));

    formatText(document.getElementsByTag("i").stream()).forEach(e -> index.addField("i", e));

    int i = 0;/*from  w  w  w .  ja v  a  2s.c  om*/
    Collection<String> text = chunkToLength(document.text());
    for (String chunk : text)
        index.addField(++i + "_text", chunk);

    return Triple.of(index, links, media);
}

From source file:com.nttec.everychan.ui.gallery.GalleryInitResult.java

public GalleryInitResult(Parcel parcel) {
    initPosition = parcel.readInt();/*from  w  w w.j a  va2  s.  c  om*/
    shouldWaitForPageLoaded = parcel.readInt() == 1;
    int n = parcel.readInt();
    attachments = new ArrayList<>(n);
    for (int i = 0; i < n; ++i) {
        AttachmentModel attachment = new AttachmentModel();
        attachment.type = parcel.readInt();
        attachment.size = parcel.readInt();
        attachment.thumbnail = parcel.readString();
        attachment.path = parcel.readString();
        attachment.width = parcel.readInt();
        attachment.height = parcel.readInt();
        attachment.originalName = parcel.readString();
        attachment.isSpoiler = parcel.readInt() == 1;
        String hash = parcel.readString();
        String post = parcel.readString();
        attachments.add(Triple.of(attachment, hash, post));
    }
}

From source file:cherry.goods.telno.TelNoNormalizerImpl.java

private List<Triple<Integer, Integer, Integer>> decompose(String telNo) {
    if (StringUtils.isEmpty(telNo)) {
        return null;
    } else if (telNo.startsWith("0120")) {
        // ??0120
        // 0120-DEF-GHJ
        return asList(Triple.of(4, 3, 3));
    } else if (telNo.startsWith("0800")) {
        // ??0800
        // 0800-DEF-GHJK
        return asList(Triple.of(4, 3, 4));
    } else if (telNo.startsWith("050")) {
        // IP??050
        // 050-CDEF-GHJK
        return asList(Triple.of(3, 4, 4));
    } else if (telNo.startsWith("070")) {
        // ?PHS??070
        // 070-CDEF-GHJK
        return asList(Triple.of(3, 4, 4));
    } else if (telNo.startsWith("080")) {
        // ?PHS??080
        // 080-CDEF-GHJK
        return asList(Triple.of(3, 4, 4));
    } else if (telNo.startsWith("090")) {
        // ?PHS??090
        // 090-CDEF-GHJK
        return asList(Triple.of(3, 4, 4));
    } else if (telNo.startsWith("020")) {
        // ??020/*w ww.  j  a  v a2 s.c  o  m*/
        // 020-CDEF-GHJK
        return asList(Triple.of(3, 4, 4));
    } else if (telNo.startsWith("0570")) {
        // ??0570
        // 0570-DEF-GHJ
        return asList(Triple.of(4, 3, 3));
    } else if (telNo.startsWith("0990")) {
        // ???0990
        // 0990-DE-FGHJ
        return asList(Triple.of(4, 2, 4));
    } else {
        // ??
        if (telNo.length() <= 2) {
            return null;
        }
        String prefix = (telNo.length() > 6 ? telNo.substring(0, 6) : telNo);
        SortedMap<String, Integer> map = areaCodeTable.prefixMap(prefix);
        if (map.isEmpty()) {
            return null;
        }
        Set<Integer> set = new TreeSet<>(map.values());
        List<Triple<Integer, Integer, Integer>> list = new ArrayList<>(set.size());
        for (Integer l : set) {
            list.add(Triple.of(l, 6 - l, 4));
        }
        return list;
    }
}

From source file:de.pixida.logtest.reporting.XUnitReportGenerator.java

@Override
public void pushExecution(final Job job, final LogSink sink, final EvaluationResult evaluationResult,
        final long timeMs) {
    List<Triple<LogSink, EvaluationResult, Long>> executions = this.results.get(job);
    if (executions == null) {
        executions = new ArrayList<>();
        this.results.put(job, executions);
    }//from w  w w  . j  a  v  a 2 s  .  c om
    executions.add(Triple.of(sink, evaluationResult, timeMs));
}