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:emily.games.game2048.Grid.java
private ArrayList<Pair<Integer, Integer>> getAvailablePositions() { ArrayList<Pair<Integer, Integer>> list = new ArrayList<>(); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (board[i][j] == 0) { list.add(Pair.of(i, j)); }//from w w w. j av a2 s.c o m } } return list; }
From source file:cherry.goods.telno.SoumuExcelParserTest.java
@Test public void testParse2() throws Exception { Map<String, Pair<String, String>> map; try (InputStream in = getClass().getResourceAsStream("soumu/000124071.xls")) { map = parser.parse(in);//ww w.java 2 s. co m } assertEquals(5683, map.size()); assertEquals(Pair.of("022", "200"), map.get("022200")); assertEquals(Pair.of("0299", "99"), map.get("029999")); }
From source file:com.ejisto.modules.vertx.handler.Translations.java
private Map<String, String> dumpMessages(ResourceBundle bundle) { return bundle.keySet().stream().map(k -> Pair.of(k, bundle.getString(k))).collect(HashMap::new, (m, p) -> m.put(p.getKey(), p.getValue()), Map::putAll); }
From source file:materialisticbiomesop.handler.FurnaceFuelHandler.java
public int getFuelValue(ItemStack stack) { if (stack == null) { return 0; }/*from w w w .ja v a 2 s.c om*/ Item item = stack.getItem(); if (item == null) { return 0; } Pair<Item, Integer> pair = Pair.of(item, stack.getItemDamage()); // see if the specific item/meta combination is registered if (itemMetaFuelList.containsKey(pair)) { return itemMetaFuelList.get(pair); } // see if the item in general is registered if (itemFuelList.containsKey(item)) { return itemFuelList.get(item); } // otherwise no value as fuel return 0; }
From source file:io.github.carlomicieli.footballdb.starter.pages.TableBuilder.java
public TableBuilder row(String... cells) { List<String> colValues = Arrays.asList(cells); checkTableSize(colValues);/*www. ja va2 s . c o m*/ values.add(colValues); size = Pair.of(size.getLeft() + 1, colValues.size()); return this; }
From source file:com.pushtechnology.mvndar.CreateManifestTaskTest.java
@Test public void test() throws Exception { when(context.getMinimumDiffusionVersion()).thenReturn("some version"); final CreateManifestTask packageManifest = new CreateManifestTask(); packageManifest.perform(context);//from w w w .j a va 2s .c om final Map<String, String> manifestEntries = archiveConfiguration.getManifestEntries(); assertEquals(1, manifestEntries.size()); assertEquals(Pair.of("Diffusion-Version", "some version"), manifestEntries.entrySet().iterator().next()); }
From source file:io.knotx.launcher.KnotxStarterVerticle.java
private Observable<Pair<String, String>> deployVerticle(final Object module) { return vertx.deployVerticleObservable((String) module, getModuleOptions((String) module)) .map(deploymentID -> Pair.of((String) module, deploymentID)); }
From source file:flens.input.GraphiteInput.java
@Override public Pair<String, BufferedReader> getStream(Socket newSocket) throws IOException { String hostname = newSocket.getInetAddress().getHostName(); return Pair.of(hostname, new BufferedReader(new InputStreamReader(newSocket.getInputStream()))); }
From source file:hu.ppke.itk.nlpg.purepos.common.lemma.SuffixLemmaTransformation.java
@Override protected Pair<String, Integer> decode(String word, String stem, Integer tag) { int i;// w ww . java2s . c o m for (i = 0; i < word.length() && i < stem.length(); ++i) { if (word.charAt(i) != stem.charAt(i)) { break; } } String wordSuff = word.substring(i); int cutSize = wordSuff.length(); String lemmaSuff = stem.substring(i); int code = SHIFT * tag + cutSize; return Pair.of(lemmaSuff, code); }
From source file:com.github.steveash.jg2p.util.CartesianProductIterableTest.java
@Test public void testIteratorThree() { CartesianProductIterable<String> set = CartesianProductIterable.of(source.subList(0, 3)); assertThat(set, contains(Pair.of("A", "B"), Pair.of("A", "C"), Pair.of("B", "C"))); assertEquals(3, Iterables.size(set)); }