ListMultimap<Long, AccumuloColumnConstraint> cardinalityToConstraints = MultimapBuilder.treeKeys().arrayListValues().build(); try { boolean earlyReturn = false;
final ListMultimap<IndexSet, String> indexSets = MultimapBuilder.hashKeys().arrayListValues().build(); for (IndexSet indexSet : this.indexSets) { final String[] managedIndicesNames = indexSet.getManagedIndices();
}) .sorted(comparing(Pair::b)) .collect(() -> hashKeys().arrayListValues().build(), (map, pair) -> map.put(pair.a(), pair.b()), Multimap::putAll);
/** * Creates a new builder. The returned builder is equivalent to the builder * generated by {@link ImmutableMultimap#builder}. */ public Builder() { this(MultimapBuilder.linkedHashKeys().arrayListValues().<K, V> build()); }
public void testGenerics_gwtCompatible() { ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().<String, Integer>build(); SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().<String, Integer>build(); SetMultimap<String, Integer> c = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER) .hashSetValues().<String, Integer>build(); }
@GwtIncompatible // doesn't build without explicit type parameters on build() methods public void testGenerics() { ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build(); SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build(); SetMultimap<String, Integer> c = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build(); }
public static Iterator<GeoWaveMetadata> groupByIds(final Iterable<GeoWaveMetadata> result) { final ListMultimap<ByteArray, GeoWaveMetadata> multimap = MultimapBuilder.hashKeys().arrayListValues().build(); result.forEach( r -> multimap.put(new ByteArray(Bytes.concat(r.getPrimaryId(), r.getSecondaryId())), r)); return multimap.values().iterator(); }
@Test public void testSerializeEntityKey() throws Exception { Entity entity = app.createAndManageChild(EntitySpec.create(BasicEntity.class)); Multimap<Entity, Integer> map = MultimapBuilder.hashKeys().arrayListValues().build(); map.put(entity, 1); map.put(entity, 2); map.put(entity, 3); String json = mapper.writer().writeValueAsString(map); assertEquals(json, "{\"BasicEntityImpl{id=" + entity.getId() + "}" + "\":[1,2,3]}"); }
@Override protected Multimap<State, State> getStateTransitions() { Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build(); result.put(State.UNINITIALISED, State.NEW); result.put(State.UNINITIALISED, State.READY); result.put(State.NEW, State.SAVE_STATE_IN_WALLET); result.put(State.SAVE_STATE_IN_WALLET, State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER); result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER, State.READY); result.put(State.READY, State.EXPIRED); result.put(State.READY, State.CLOSED); return result; }
@Override protected Multimap<State, State> getStateTransitions() { Multimap<State, State> result = MultimapBuilder.enumKeys(State.class).arrayListValues().build(); result.put(State.UNINITIALISED, State.NEW); result.put(State.UNINITIALISED, State.READY); result.put(State.NEW, State.SAVE_STATE_IN_WALLET); result.put(State.SAVE_STATE_IN_WALLET, State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER); result.put(State.PROVIDE_MULTISIG_CONTRACT_TO_SERVER, State.READY); result.put(State.READY, State.EXPIRED); result.put(State.READY, State.CLOSED); return result; }
@GwtIncompatible // doesn't build without explicit type parameters on build() methods public void testTreeKeys() { ListMultimap<String, Integer> multimap = MultimapBuilder.treeKeys().arrayListValues().build(); assertTrue(multimap.keySet() instanceof SortedSet); assertTrue(multimap.asMap() instanceof SortedMap); }
private void addMetadata(JCas jCas, Document doc) { Multimap<String, Object> meta = MultimapBuilder.linkedHashKeys().linkedListValues().build(); for (Metadata metadata : JCasUtil.select(jCas, Metadata.class)) { String key = metadata.getKey(); if (key.contains(".")) { // Field names can't contain a "." in Mongo, so replace with a _ key = key.replaceAll("\\.", "_"); } meta.put(key, metadata.getValue()); } doc.append(FIELD_METADATA, meta.asMap()); }
public ClasspathEntrySnapshotBuilder(ResourceHasher classpathResourceHasher, StringInterner stringInterner) { this.classpathResourceHasher = classpathResourceHasher; this.stringInterner = stringInterner; this.normalizedSnapshots = MultimapBuilder.hashKeys().arrayListValues().build(); }
private Multimap<String, String> getParameters(Element element) { ListMultimap<String, String> result = MultimapBuilder.hashKeys().arrayListValues().build(); for (Object paramElem : element.elements("param")) { Element param = (Element) paramElem; String name = getAttributeOrThrow(param, "name"); result.put(name, getAttribute(param, "value").orElse(param.getStringValue())); } return result; }
@Test public void testSerializeStringKey() throws Exception { Multimap<String, Integer> map = MultimapBuilder.hashKeys().arrayListValues().build(); map.put("a", 1); map.put("a", 2); map.put("a", 3); String json = mapper.writer().writeValueAsString(map); assertEquals(json, "{\"a\":[1,2,3]}"); }
public void testFlatteningToMultimap() { Collector<String, ?, ListMultimap<Character, Character>> collector = Multimaps.flatteningToMultimap( str -> str.charAt(0), str -> str.substring(1).chars().mapToObj(c -> (char) c), MultimapBuilder.linkedHashKeys().arrayListValues()::build); BiPredicate<Multimap<?, ?>, Multimap<?, ?>> equivalence = Equivalence.equals() .onResultOf((Multimap<?, ?> mm) -> ImmutableList.copyOf(mm.asMap().entrySet())) .and(Equivalence.equals()); ListMultimap<Character, Character> empty = MultimapBuilder.linkedHashKeys().arrayListValues().build(); ListMultimap<Character, Character> filled = MultimapBuilder.linkedHashKeys().arrayListValues().build(); filled.putAll('b', Arrays.asList('a', 'n', 'a', 'n', 'a')); filled.putAll('a', Arrays.asList('p', 'p', 'l', 'e')); filled.putAll('c', Arrays.asList('a', 'r', 'r', 'o', 't')); filled.putAll('a', Arrays.asList('s', 'p', 'a', 'r', 'a', 'g', 'u', 's')); filled.putAll('c', Arrays.asList('h', 'e', 'r', 'r', 'y')); CollectorTester.of(collector, equivalence) .expectCollects(empty) .expectCollects(filled, "banana", "apple", "carrot", "asparagus", "cherry"); }
public void testGenerics_gwtCompatible() { ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().<String, Integer>build(); SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().<String, Integer>build(); SetMultimap<String, Integer> c = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER) .hashSetValues() .<String, Integer>build(); }
public void testTreeKeys_gwtCompatible() { ListMultimap<String, Integer> multimap = MultimapBuilder.treeKeys().arrayListValues().<String, Integer>build(); assertTrue(multimap.keySet() instanceof SortedSet); assertTrue(multimap.asMap() instanceof SortedMap); }
@GwtIncompatible // doesn't build without explicit type parameters on build() methods public void testGenerics() { ListMultimap<String, Integer> a = MultimapBuilder.hashKeys().arrayListValues().build(); SortedSetMultimap<String, Integer> b = MultimapBuilder.linkedHashKeys().treeSetValues().build(); SetMultimap<String, Integer> c = MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).hashSetValues().build(); }
@GwtIncompatible // doesn't build without explicit type parameters on build() methods public void testTreeKeys() { ListMultimap<String, Integer> multimap = MultimapBuilder.treeKeys().arrayListValues().build(); assertTrue(multimap.keySet() instanceof SortedSet); assertTrue(multimap.asMap() instanceof SortedMap); }