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

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

Introduction

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

Prototype

public static <L, R> ImmutablePair<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:im.dadoo.cedar.condition.Conditions.java

public static Condition between(String field, String begin, String end) {
    return new Condition(field, Operation.BETWEEN,
            ImmutablePair.of(Util.placeholder(begin), Util.placeholder(end)));
}

From source file:com.addthis.hydra.job.store.CachedSpawnDataStore.java

private static Pair<String, String> defaultKey(String path) {
    return ImmutablePair.of(path, null);
}

From source file:io.github.carlomicieli.footballdb.starter.utils.MapUtils.java

public static <K, V> ImmutablePair<K, V> pair(K k, V v) {
    return ImmutablePair.of(k, v);
}

From source file:com.ethylamine.fsynthesis.util.position.ChunkCoord.java

private ChunkCoord(int x, int z) {
    data = ImmutablePair.of(x, z);
}

From source file:cc.kave.commons.pointsto.evaluation.ProjectTrainValidateEvaluation.java

public static void main(String[] args) throws IOException {
    Locale.setDefault(Locale.US);

    Path baseDir = Paths.get("E:\\Coding\\MT");
    Path usageStoresDir = baseDir.resolve("Usages");
    Path resultFile = baseDir.resolve("EvaluationResults").resolve("TrainValidate.txt");

    ProjectTrainValidateEvaluation evaluator = INJECTOR.getInstance(ProjectTrainValidateEvaluation.class);
    evaluator.run(usageStoresDir);/*ww w .j  a v  a 2  s .  c  o m*/

    INJECTOR.getInstance(ResultExporter.class).export(resultFile, evaluator.getResults().entrySet().stream()
            .flatMap(e -> e.getValue().stream().map(er -> ImmutablePair.of(e.getKey(), er))).map(p -> {
                return new String[] { CoReNames.vm2srcQualifiedType(p.left), p.right.training,
                        p.right.validation, String.format(Locale.US, "%.3f", p.right.score),
                        Integer.toString(p.right.numTrainingUsages),
                        Integer.toString(p.right.numValidationUsages) };
            }));

    INJECTOR.getInstance(ExecutorService.class).shutdown();
}

From source file:com.wrmsr.kleist.util.Itertools.java

public static <L, R> Iterator<Pair<L, R>> zip(Iterator<L> left, Iterator<R> right) {
    return new Iterator<Pair<L, R>>() {
        @Override/*  w  w  w. j  av  a  2  s .  c  o m*/
        public boolean hasNext() {
            return left.hasNext() && right.hasNext();
        }

        @Override
        public Pair<L, R> next() {
            return ImmutablePair.of(left.next(), right.next());
        }
    };
}

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

protected Table(TableBuilder tb) {
    this.size = ImmutablePair.of(tb.size.getKey(), tb.size.getValue());
    this.headers = Collections.unmodifiableList(tb.columnHeaders);
    this.rows = tb.values.stream().map(r -> Row.of(r, headers)).collect(Collectors.toList());
}

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

@Test
public void shouldBuildNewTablesFromElements() {
    Optional<Table> table = TableBuilder.fromElement(tableElement());

    Table tab = table.orElseThrow(RuntimeException::new);

    assertThat(tab.size()).isEqualTo(ImmutablePair.of(3, 3));
    assertThat(tab.rowValues(1)).contains(Arrays.asList("1", "one", "3"));
    assertThat(tab.rowValues(2)).contains(Arrays.asList("", "", ""));
    assertThat(tab.rowValues(3)).contains(Arrays.asList("2", "two", "1"));
}

From source file:com.wrmsr.wava.basic.BasicSet.java

public static BasicSet build(Stream<Basic> basics) {
    return new BasicSet(basics.map(basic -> {
        checkArgument(!Basics.TERMINAL_NAMES.contains(basic.getName()));
        return ImmutablePair.of(basic.getName(), basic);
    }).collect(toPersistentHashMap()));//  w w  w .  j  a v a2  s  .c  o m
}

From source file:io.mapzone.controller.provision.ProvisionExecutor.java

public ProvisionExecutor(Class<? extends Provision>[] preliminaries) {
    this.preliminaries = preliminaries;

    contextValues = new HashMap();
    contextFactory = new ContextFactory() {
        @Override/*from   w  w w  .  j  av a  2s.co  m*/
        protected void setValue(Class type, String scope, Object value) {
            if (value != null) {
                contextValues.put(ImmutablePair.of(type, scope), value);
            } else {
                contextValues.remove(ImmutablePair.of(type, scope));
            }
        }

        @Override
        protected Object getValue(Class type, String scope) {
            return contextValues.get(ImmutablePair.of(type, scope));
        }
    };
}