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.kantenkugel.kanzebot.api.command.CommandGroup.java

public CommandGroup(Command... subCommands) {
    this.subCommands = new HashMap<>();
    for (Command subCommand : subCommands) {
        this.subCommands.put(subCommand.getKey(), Pair.of(subCommand, subCommand.getCustomParser()));
    }/*  ww w  .  j a  va  2  s.co  m*/
}

From source file:controllers.api.ApiAuthenticationBizdockCheck.java

@Override
public Pair<Boolean, String> before() {
    ILicensesManagementService licensesManagementService = Play.application().injector()
            .instanceOf(ILicensesManagementService.class);

    if (licensesManagementService != null && !licensesManagementService.isInstanceAccessible()) {
        return Pair.of(false, "the instance is not accessible");
    }/*from  w w w .ja  v  a  2 s .  c  o m*/
    return Pair.of(true, null);
}

From source file:com.nesscomputing.jdbi.mapper.PairMapper.java

@Override
public Pair<U, V> map(int index, final ResultSet r, final StatementContext ctx) throws SQLException {
    final U leftValue = leftMapper.map(index, r, ctx);
    final V rightValue = rightMapper.map(index, r, ctx);

    return Pair.of(leftValue, rightValue);
}

From source file:de.tuberlin.uebb.jbop.optimizer.methodsplitter.VarList.java

public Pair<Var, Var> getBounds(final int index) {
    return Pair.of(getFirstVar(index), getLastVar(index));
}

From source file:com.spotify.heroic.suggest.TagSuggest.java

public static Collector<TagSuggest, TagSuggest> reduce(final OptionalLimit limit) {
    return groups -> {
        final List<RequestError> errors1 = new ArrayList<>();
        final Map<Pair<String, String>, Float> suggestions1 = new HashMap<>();

        for (final TagSuggest g : groups) {
            errors1.addAll(g.errors);/*w ww. j  av  a2  s.co m*/

            for (final Suggestion s : g.suggestions) {
                final Pair<String, String> key = Pair.of(s.getKey(), s.getValue());
                final Float old = suggestions1.put(key, s.getScore());

                // prefer higher score if available.
                if (old != null && s.score < old) {
                    suggestions1.put(key, old);
                }
            }
        }

        final List<Suggestion> values = ImmutableList.copyOf(ImmutableSortedSet.copyOf(suggestions1.entrySet()
                .stream().map(e -> new Suggestion(e.getValue(), e.getKey().getLeft(), e.getKey().getRight()))
                .iterator()));

        return new TagSuggest(errors1, limit.limitList(values));
    };
}

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

/**
 * Test method for {@link BiSupplierThrowable#get()}.
 *//*from w  w  w  . j av a  2 s.  com*/
@Test
public void testGet() {
    boolean test = false;
    final String error = "error";

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

    try {
        assertEquals("(l,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:com.hortonworks.registries.storage.impl.jdbc.provider.sql.query.AbstractStorableUpdateQuery.java

public AbstractStorableUpdateQuery(Storable storable) {
    super(storable);
    Map<String, Object> columnsToValues = storable.toMap();
    columns.forEach(col -> bindings.add(Pair.of(col, columnsToValues.get(col.getName()))));
    primaryKey.getFieldsToVal().forEach((f, o) -> {
        bindings.add(Pair.of(f, o));//from   w  w w . j a  v a  2  s .com
        whereFields.add(f);
    });
    try {
        Optional<Pair<Field, Long>> versionFieldValue = StorageUtils.getVersionFieldValue(storable);
        if (versionFieldValue.isPresent()) {
            Pair<Field, Long> fv = versionFieldValue.get();
            Schema.Field versionField = Schema.Field.of(fv.getKey().getName(),
                    Schema.fromJavaType(fv.getValue().getClass()));
            whereFields.add(versionField);
            // update only if its the previous
            bindings.add(Pair.of(versionField, fv.getValue() - 1));
        }
    } catch (Exception ex) {
        LOG.error("Got exception", ex);
    }
}

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

@Test
public void testParse1() throws Exception {
    Map<String, Pair<String, String>> map;
    try (InputStream in = getClass().getResourceAsStream("soumu/000124070.xls")) {
        map = parser.parse(in);/*from w ww  .  j  av  a  2  s .c  o m*/
    }
    assertEquals(4554, map.size());
    assertEquals(Pair.of("011", "200"), map.get("011200"));
    assertEquals(Pair.of("0198", "79"), map.get("019879"));
}

From source file:com.muk.ext.core.jackson.PairDeserializer.java

@Override
public Pair<String, Object> deserialize(JsonParser p, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    final Object[] array = p.readValueAs(Object[].class);
    return Pair.of((String) array[0], array[1]);
}

From source file:flens.filter.RenameFilter.java

public RenameFilter(String name, Tagger tagger, Matcher matcher, int prio, List<String> f, List<String> t) {
    super(name, tagger, matcher, prio);
    for (int i = 0; i < f.size(); i++)
        this.names.add(Pair.of(f.get(i), t.get(i)));
}