List of usage examples for org.apache.commons.lang3.tuple Pair of
public static <L, R> Pair<L, R> of(final L left, final R right)
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.
From source file:de.codecentric.batch.metrics.BatchMetricsImpl.java
@Override public void reset(String metricName) { if (TransactionSynchronizationManager.isSynchronizationActive()) { initializeMetricContainerAndRegisterTransactionSynchronizationIfNecessary(); metricContainer.get().metrics.add(Pair.of(metricName, (Number) null)); } else {/*from w w w.j a v a 2 s . c om*/ resetNonTransactional(metricName); } }
From source file:edu.umd.umiacs.clip.tools.classifier.LibSVMUtils.java
public static List<String> addValues(List<String>... input) { return addValues(Stream.of(input).map(list -> Pair.of(1d, list)).collect(toList())); }
From source file:mtsar.processors.task.InverseCountAllocatorTest.java
@Test public void testUnequalAllocation() { when(countDAO.getCountsSQL(anyString())).thenReturn(Arrays.asList(Pair.of(1, 1), Pair.of(2, 0))); final TaskAllocator allocator = new InverseCountAllocator(stage, dbi, taskDAO, answerDAO); final Optional<TaskAllocation> optional = allocator.allocate(worker); assertThat(optional.isPresent()).isTrue(); final TaskAllocation allocation = optional.get(); assertThat(allocation.getTask().get().getId()).isEqualTo(2); assertThat(allocation.getTaskRemaining()).isEqualTo(2); assertThat(allocation.getTaskCount()).isEqualTo(2); }
From source file:alfio.controller.api.admin.LocationApiController.java
@RequestMapping(value = "/location/map", method = GET) public String getMapUrl(@RequestParam("lat") String latitude, @RequestParam("long") String longitude) { Validate.notBlank(latitude);//from w ww . ja v a 2 s . c o m Validate.notBlank(longitude); LocationDescriptor descriptor = LocationDescriptor.fromGeoData(Pair.of(latitude, longitude), TimeZone.getDefault(), getMapsClientApiKey()); return descriptor.getMapUrl(); }
From source file:com.yahoo.bullet.parsing.ProjectionTest.java
@Test public void testRepeatedProjections() { Projection first = new Projection(); first.setFields(singletonMap("field", "id")); Projection second = new Projection(); second.setFields(singletonMap("map_field.foo", "bar")); RecordBox box = RecordBox.get().add("field", "test").addMap("map_field", Pair.of("foo", "baz")); BulletRecord record = box.getRecord(); BulletRecord firstProjection = first.project(record); BulletRecord secondProjection = second.project(record); box = RecordBox.get().add("field", "test").addMap("map_field", Pair.of("foo", "baz")); BulletRecord expectedOriginal = box.getRecord(); Assert.assertEquals(record, expectedOriginal); box = RecordBox.get().add("id", "test"); BulletRecord expectedFirstProjection = box.getRecord(); Assert.assertEquals(firstProjection, expectedFirstProjection); box = RecordBox.get().add("bar", "baz"); BulletRecord expectedSecondProjection = box.getRecord(); Assert.assertEquals(secondProjection, expectedSecondProjection); }
From source file:atg.tools.dynunit.internal.reflect.ClassReflection.java
@Nullable public <A extends Annotation> Pair<? extends AnnotatedElement, A> getAnnotatedElement( @NotNull final Class<A> annotationClass) { logger.entry(annotationClass);//from ww w . ja v a 2s.co m A annotation = getClassAnnotation(annotationClass); if (annotation != null) { return logger.exit(Pair.of(klass, annotation)); } for (final Field field : fields) { annotation = getFieldAnnotation(field, annotationClass); if (annotation != null) { return logger.exit(Pair.of(field, annotation)); } } for (final Method method : methods) { annotation = getMethodAnnotation(method, annotationClass); if (annotation != null) { return logger.exit(Pair.of(method, annotation)); } } return logger.exit(null); }
From source file:cherry.goods.telno.SoumuExcelParserTest.java
@Test public void testParse5() throws Exception { Map<String, Pair<String, String>> map; try (InputStream in = getClass().getResourceAsStream("soumu/000124074.xls")) { map = parser.parse(in);//from w ww . j a va2 s . com } assertEquals(5307, map.size()); assertEquals(Pair.of("052", "200"), map.get("052200")); assertEquals(Pair.of("0599", "89"), map.get("059989")); }
From source file:io.gameover.utilities.pixeleditor.Frame.java
public List<Pair<Integer, Integer>> extractColors() { Map<Integer, Integer> m = new HashMap<>(); for (int i = 0; i < argb.length; i++) { for (int j = 0; j < argb[0].length; j++) { int c = argb[i][j]; if (!m.containsKey(c)) { m.put(c, 1);//from w ww. j a v a 2 s . c om } else { m.put(c, m.get(c) + 1); } } } List<Pair<Integer, Integer>> ret = new ArrayList<>(); for (Integer k : m.keySet()) { ret.add(Pair.of(k, m.get(k))); } Collections.sort(ret, new Comparator<Pair<Integer, Integer>>() { @Override public int compare(Pair<Integer, Integer> o1, Pair<Integer, Integer> o2) { return o2.getValue() - o1.getValue(); } }); return ret; }
From source file:it.anyplace.sync.bep.FolderBrowser.java
public List<Pair<FolderInfo, FolderStats>> getFolderInfoAndStatsList() { return Lists.newArrayList(Iterables.transform(indexHandler.getFolderInfoList(), new Function<FolderInfo, Pair<FolderInfo, FolderStats>>() { @Override//from w w w. java 2 s. c o m public Pair<FolderInfo, FolderStats> apply(FolderInfo folderInfo) { return Pair.of(folderInfo, getFolderStats(folderInfo.getFolder())); } })); }
From source file:enumj.EnumeratorTest.java
@Test public void testOn() { System.out.println("on"); EnumeratorGenerator.generatorPairs().limit(100) .map(p -> Pair.of(p.getLeft().onEnumerator(), p.getRight().onEnumerator())) .forEach(p -> assertTrue(p.getLeft().elementsEqual(p.getRight()))); }