@Override public <K extends K0, V> ListMultimap<K, V> build() { return Multimaps.newListMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new ArrayListSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V> ListMultimap<K, V> build() { return Multimaps.newListMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), LinkedListSupplier.<V>instance()); } };
@Override public <K extends K0, V> ListMultimap<K, V> build() { return Multimaps.newListMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new ArrayListSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V> ListMultimap<K, V> build() { return Multimaps.newListMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), LinkedListSupplier.<V>instance()); } };
public ClassProperties(Class clazz) { methods = Multimaps.newListMultimap( new TreeMap<>(String.CASE_INSENSITIVE_ORDER), () -> new ArrayList<>()); getters = Multimaps.newListMultimap( new TreeMap<>(String.CASE_INSENSITIVE_ORDER), () -> new ArrayList<>()); setters = Multimaps.newListMultimap( new TreeMap<>(String.CASE_INSENSITIVE_ORDER), () -> new ArrayList<>()); for (Method method : clazz.getMethods()) { final String name = method.getName(); methods.put(name, method); final Class<?>[] params = method.getParameterTypes(); if ((name.startsWith("get") || name.startsWith("is") || COMMON_DERIVED_PROPERTIES.contains(name)) && params.length == 0) { getters.put(gp(method), method); } else if (name.startsWith("set") && params.length == 1) { setters.put(name.substring(3), method); } } // avoid keeping lots of useless empty arrays in memory for // the long term, use just one if (methods.size() == 0) methods = EMPTY; if (getters.size() == 0) getters = EMPTY; if (setters.size() == 0) setters = EMPTY; }
@Override public <K extends K0, V> ListMultimap<K, V> build() { return Multimaps.newListMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), LinkedListSupplier.<V>instance()); } };
@Override public <K extends K0, V> ListMultimap<K, V> build() { return Multimaps.newListMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new ArrayListSupplier<V>(expectedValuesPerKey)); } };
@GwtIncompatible // SerializableTester public void testNewListMultimapSerialization() { CountingSupplier<LinkedList<Integer>> factory = new ListSupplier(); Map<Color, Collection<Integer>> map = Maps.newTreeMap(); ListMultimap<Color, Integer> multimap = Multimaps.newListMultimap(map, factory); multimap.putAll(Color.BLUE, asList(3, 1, 4, 1)); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); SerializableTester.reserializeAndAssert(multimap); }
Multimaps.newListMultimap( new LinkedHashMap<Thread, Collection<ID>>(), new Supplier<List<ID>>() {
public void testNewListMultimap() { CountingSupplier<LinkedList<Integer>> factory = new ListSupplier(); Map<Color, Collection<Integer>> map = Maps.newTreeMap(); ListMultimap<Color, Integer> multimap = Multimaps.newListMultimap(map, factory); assertEquals(0, factory.count); multimap.putAll(Color.BLUE, asList(3, 1, 4, 1)); assertEquals(1, factory.count); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); assertEquals(2, factory.count); assertEquals("{BLUE=[3, 1, 4, 1], RED=[2, 7, 1, 8]}", multimap.toString()); assertFalse(multimap.get(Color.BLUE) instanceof RandomAccess); assertTrue(multimap.keySet() instanceof SortedSet); assertTrue(multimap.asMap() instanceof SortedMap); }
public Multimap<LockClient, LockRequestProgress> getSuspectedLockProgress() { Multimap<LockClient, LockRequestProgress> result = Multimaps.newListMultimap( Maps.newHashMap(), Lists::newArrayList); for (Map.Entry<LockClient, Set<LockRequest>> entry : outstandingLockRequests.entrySet()) { for (LockRequest lockRequest : entry.getValue()) { result.put(entry.getKey(), getSuspectedLockProgress(entry.getKey(), lockRequest)); } } return result; }
/** * Creates a new, empty {@code ListMultimap} with the default initial capacities that uses a linked map internally. */ public static <K, V> ListMultimap<K, V> newLinkedHashListMultimap() { return Multimaps.newListMultimap(Maps.<K, Collection<V>> newLinkedHashMap(), new Supplier<List<V>>() { @Override public List<V> get() { return Lists.newArrayList(); } }); }
static public <K,V>ListMultimap<K,V> getArrayListMultiHashMap() { ListMultimap<K,V> map = Multimaps.newListMultimap(Maps.<K,Collection<V>>newHashMap(), new Supplier<List<V>>() { public List<V> get() {return Lists.newArrayList();} }); return map; } }
private static ListMultimap<String, String> newListMultimap() { return Multimaps.newListMultimap( Maps.<String, Collection<String>>newLinkedHashMap(), new Supplier<List<String>>() { @Override public List<String> get() { return Lists.newArrayList(); } }); } }
@javax.inject.Inject public ComponentFactoryRegistryDefault(final ComponentFactoryRegistrar componentFactoryList) { componentFactoriesByType = Multimaps.newListMultimap(new HashMap<ComponentType, Collection<ComponentFactory>>(), new Supplier<List<ComponentFactory>>() { @Override public List<ComponentFactory> get() { return Lists.newArrayList(); } }); registerComponentFactories(componentFactoryList); }
@Override public <K extends K0, V> ListMultimap<K, V> build() { return Multimaps.newListMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), LinkedListSupplier.<V>instance()); } };
@Override public <K extends K0, V> ListMultimap<K, V> build() { return Multimaps.newListMultimap( MultimapBuilderWithKeys.this.<K, V> createMap(), new ArrayListSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V> ListMultimap<K, V> build() { return Multimaps.newListMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), new ArrayListSupplier<V>(expectedValuesPerKey)); } };
@Override public <K extends K0, V> ListMultimap<K, V> build() { return Multimaps.newListMultimap( MultimapBuilderWithKeys.this.<K, V>createMap(), LinkedListSupplier.<V>instance()); } };
@GwtIncompatible // SerializableTester public void testNewListMultimapSerialization() { CountingSupplier<LinkedList<Integer>> factory = new ListSupplier(); Map<Color, Collection<Integer>> map = Maps.newTreeMap(); ListMultimap<Color, Integer> multimap = Multimaps.newListMultimap(map, factory); multimap.putAll(Color.BLUE, asList(3, 1, 4, 1)); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); SerializableTester.reserializeAndAssert(multimap); }