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:net.lyonlancer5.mcmp.kawo.modes.BookProcessor.java

public static List<Pair<String, String>> readBook(ItemStack book) {
    if (book.getTagCompound() == null) {
        return ImmutableList.of();
    }/*  www  .  j av a  2  s.  co m*/

    NBTTagList pages = book.getTagCompound().getTagList("pages", 8);

    if (pages == null || pages.tagCount() == 0) {
        return ImmutableList.of();
    }

    final List<Pair<String, String>> lines = Lists.newArrayList();
    for (int i = 0; i < pages.tagCount(); i++) {
        String[] crlf = pages.getStringTagAt(i).split("[\\r\\n]");
        for (String ln : crlf) {
            ln = ln.trim();
            if (!ln.isEmpty()) {
                if (ln.contains("=")) {
                    String[] var0 = ln.split("=", 2);
                    lines.add(Pair.of(var0[0].trim(), var0[1].trim()));
                }
            }
        }
    }
    return ImmutableList.copyOf(lines);
}

From source file:com.tussle.motion.CollisionMap.java

public ProjectionVector put(StageElement<CollisionStadium> c, StageElement s, ProjectionVector p) {
    return put(Pair.of(c, s), p);
}

From source file:alfio.controller.support.TemplateProcessorTest.java

@Test
public void resultingImageMustBeUnder300x150() {
    Stream.generate(//  w ww .  j  a  v a2 s. c o m
            () -> Pair.of(String.valueOf(random.nextInt(10_000)), String.valueOf(random.nextInt(100_000))))
            .limit(1000).forEach(this::assertDimensionsUnder300x150);
}

From source file:io.github.carlomicieli.footballdb.starter.pages.TableBuilder.java

protected TableBuilder() {
    size = Pair.of(0, 0);
}

From source file:com.github.steveash.jg2p.align.ProbTable.java

private static void addAllPresent(ProbTable tbl, Set<Pair<String, String>> output) {
    for (Table.Cell<String, String, Double> aa : tbl) {
        if (aa.getValue() != null && aa.getValue() > 0) {
            output.add(Pair.of(aa.getRowKey(), aa.getColumnKey()));
        }//from w  w w.  j  a v a 2  s. co m
    }
}

From source file:net.minecraftforge.client.MinecraftForgeClient.java

public static void onRebuildChunk(World world, BlockPos position, RegionRenderCache cache) {
    regionCache.put(Pair.of(world, position), cache);
}

From source file:com.yahoo.bullet.parsing.ProjectionTest.java

@Test
public void testProjection() {
    Projection projection = new Projection();
    projection.setFields(singletonMap("map_field.foo", "bar"));
    RecordBox box = RecordBox.get().addMap("map_field", Pair.of("foo", "baz"));
    BulletRecord actual = projection.project(box.getRecord());
    BulletRecord expected = RecordBox.get().add("bar", "baz").getRecord();
    Assert.assertEquals(actual, expected);
}

From source file:com.github.steveash.jg2p.util.Zipper.java

public static <A, B> List<Pair<A, B>> replaceRight(List<Pair<A, B>> original, Iterable<B> newRight) {
    ArrayList<Pair<A, B>> result = Lists.newArrayListWithCapacity(original.size());
    Iterator<B> iter = newRight.iterator();
    for (Pair<A, B> pair : original) {
        Preconditions.checkArgument(iter.hasNext(), "newRight is smaller than original");
        result.add(Pair.of(pair.getLeft(), iter.next()));
    }//from  w  ww.  jav  a  2 s  .  c  o  m
    Preconditions.checkArgument(!iter.hasNext(), "newRight is bigger than original");
    return result;
}

From source file:com.uber.hoodie.table.WorkloadStat.java

long addUpdates(HoodieRecordLocation location, long numUpdates) {
    updateLocationToCount.put(location.getFileId(), Pair.of(location.getCommitTime(), numUpdates));
    return this.numUpdates += numUpdates;
}

From source file:alfio.model.TicketFieldConfigurationAndDescription.java

public List<Pair<String, String>> getTranslatedRestrictedValue() {
    Map<String, String> description = ticketFieldDescription.getRestrictedValuesDescription();
    return ticketFieldConfiguration.getRestrictedValues().stream()
            .map(val -> Pair.of(val, description.getOrDefault(val, "MISSING_DESCRIPTION")))
            .collect(Collectors.toList());
}