@Override public <K extends K0, V> SetMultimap<K, V> build() { return Multimaps.newSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new LinkedHashSetSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V> SetMultimap<K, V> build() { return Multimaps.newSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new HashSetSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V extends V0> SetMultimap<K, V> build() { // V must actually be V0, since enums are effectively final // (their subclasses are inaccessible) @SuppressWarnings({"unchecked", "rawtypes"}) Supplier<Set<V>> factory = (Supplier) new EnumSetSupplier<V0>(valueClass); return Multimaps.newSetMultimap(MultimapBuilderWithKeys.this.<K, V>createMap(), factory); } };
public Multimap deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { final SetMultimap<String,String> map = Multimaps.newSetMultimap(new HashMap<String, Collection<String>>(), new Supplier<Set<String>>() { public Set<String> get() { return Sets.newHashSet(); } }); for (Map.Entry<String, JsonElement> entry : ((JsonObject) jsonElement).entrySet()) { for (JsonElement element : (JsonArray) entry.getValue()) { map.get(entry.getKey()).add(element.getAsString()); } } return map; } })
public Multimap deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { final SetMultimap<String,String> map = Multimaps.newSetMultimap(new HashMap<String, Collection<String>>(), new Supplier<Set<String>>() { public Set<String> get() { return Sets.newHashSet(); } }); for (Map.Entry<String, JsonElement> entry : ((JsonObject) jsonElement).entrySet()) { for (JsonElement element : (JsonArray) entry.getValue()) { map.get(entry.getKey()).add(element.getAsString()); } } return map; } })
/** get or create the multimap object for the given {@code index} */ public Multimap<String, String> getOrCreate(String index) { Multimap<String, String> mmap = storeMap.get(index); if (mmap == null) { SetMultimap<String, String> multimap = Multimaps.newSetMultimap(new HashMap<String, Collection<String>>(), new Supplier<Set<String>>() { public Set<String> get() { return Sets.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); } }); mmap = concurrent ? Multimaps.synchronizedSetMultimap(multimap) : multimap; storeMap.put(index,mmap); } return mmap; }
/** get or create the multimap object for the given {@code index} */ public Multimap<String, String> getOrCreate(String index) { Multimap<String, String> mmap = storeMap.get(index); if (mmap == null) { SetMultimap<String, String> multimap = Multimaps.newSetMultimap(new HashMap<String, Collection<String>>(), new Supplier<Set<String>>() { public Set<String> get() { return Sets.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); } }); mmap = concurrent ? Multimaps.synchronizedSetMultimap(multimap) : multimap; storeMap.put(index,mmap); } return mmap; }
@Override public <K extends K0, V> SetMultimap<K, V> build() { return Multimaps.newSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new HashSetSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V extends V0> SetMultimap<K, V> build() { // V must actually be V0, since enums are effectively final // (their subclasses are inaccessible) @SuppressWarnings({"unchecked", "rawtypes"}) Supplier<Set<V>> factory = (Supplier) new EnumSetSupplier<V0>(valueClass); return Multimaps.newSetMultimap(MultimapBuilderWithKeys.this.<K, V>createMap(), factory); } };
@Override public <K extends K0, V> SetMultimap<K, V> build() { return Multimaps.newSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new LinkedHashSetSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V> SetMultimap<K, V> build() { return Multimaps.newSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new HashSetSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V extends V0> SetMultimap<K, V> build() { // V must actually be V0, since enums are effectively final // (their subclasses are inaccessible) @SuppressWarnings({"unchecked", "rawtypes"}) Supplier<Set<V>> factory = (Supplier) new EnumSetSupplier<V0>(valueClass); return Multimaps.newSetMultimap(MultimapBuilderWithKeys.this.<K, V>createMap(), factory); } };
@Override public <K extends K0, V> SetMultimap<K, V> build() { return Multimaps.newSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new LinkedHashSetSupplier<V>(expectedValuesPerKey)); } };
@GwtIncompatible // SerializableTester public void testNewSetMultimapSerialization() { CountingSupplier<Set<Integer>> factory = new SetSupplier(); Map<Color, Collection<Integer>> map = Maps.newHashMap(); SetMultimap<Color, Integer> multimap = Multimaps.newSetMultimap(map, factory); multimap.putAll(Color.BLUE, asList(3, 1, 4)); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); SerializableTester.reserializeAndAssert(multimap); }
public void testNewSetMultimap() { CountingSupplier<Set<Integer>> factory = new SetSupplier(); Map<Color, Collection<Integer>> map = Maps.newHashMap(); SetMultimap<Color, Integer> multimap = Multimaps.newSetMultimap(map, factory); assertEquals(0, factory.count); multimap.putAll(Color.BLUE, asList(3, 1, 4)); assertEquals(1, factory.count); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); assertEquals(2, factory.count); assertEquals(Sets.newHashSet(4, 3, 1), multimap.get(Color.BLUE)); }
final Multimap<String,String> methods = Multimaps.newSetMultimap(new HashMap<String, Collection<String>>(), new Supplier<Set<String>>() { public Set<String> get() { return Sets.newHashSet();
final Multimap<String,String> methods = Multimaps.newSetMultimap(new HashMap<String, Collection<String>>(), new Supplier<Set<String>>() { public Set<String> get() { return Sets.newHashSet();
@Override public <K extends K0, V> SetMultimap<K, V> build() { return Multimaps.newSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new HashSetSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V> SetMultimap<K, V> build() { return Multimaps.newSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new HashSetSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V extends V0> SetMultimap<K, V> build() { // V must actually be V0, since enums are effectively final // (their subclasses are inaccessible) @SuppressWarnings({"unchecked", "rawtypes"}) Supplier<Set<V>> factory = (Supplier) new EnumSetSupplier<V0>(valueClass); return Multimaps.newSetMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), factory); } };