List of usage examples for com.google.common.collect Multimaps newListMultimap
public static <K, V> ListMultimap<K, V> newListMultimap(Map<K, Collection<V>> map, final Supplier<? extends List<V>> factory)
From source file:se.curity.examples.oauth.FilterHelper.java
static ImmutableMultimap<String, String> initParamsMapFrom(FilterConfig config) { Multimap<String, String> result = Multimaps.newListMultimap(new LinkedHashMap<>(), ArrayList::new); Enumeration<?> names = config.getInitParameterNames(); while (names.hasMoreElements()) { String name = names.nextElement().toString(); if (config.getInitParameter(name) != null) { result.put(name, config.getInitParameter(name)); }// ww w.j ava 2s . c o m } return ImmutableMultimap.copyOf(result); }
From source file:org.summer.dsl.xbase.typesystem.util.Multimaps2.java
/** * Creates a new, empty {@code ListMultimap} with the default initial capacities that uses a linked map internally. */// www .j av a 2 s. co m public static <K, V> ListMultimap<K, V> newLinkedHashListMultimap() { return Multimaps.newListMultimap(Maps.<K, Collection<V>>newLinkedHashMap(), new Supplier<List<V>>() { public List<V> get() { return Lists.newArrayList(); } }); }
From source file:org.eclipse.xtext.xbase.typesystem.util.Multimaps2.java
/** * Creates a new, empty {@code ListMultimap} with the default initial capacities that uses a linked map internally. *//*from w w w .ja v a2 s. c o m*/ 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(); } }); }
From source file:org.summer.dsl.xbase.typesystem.util.Multimaps2.java
/** * Constructs an empty {@code ListMultimap} with enough capacity to hold the specified numbers of keys and values * without resizing. It uses a linked map internally. * //from www. ja va2 s . c o m * @param expectedKeys * the expected number of distinct keys * @param expectedValuesPerKey * the expected average number of values per key * @throws IllegalArgumentException * if {@code expectedKeys} or {@code expectedValuesPerKey} is negative */ public static <K, V> ListMultimap<K, V> newLinkedHashListMultimap(int expectedKeys, final int expectedValuesPerKey) { return Multimaps.newListMultimap(new LinkedHashMap<K, Collection<V>>(expectedKeys), new Supplier<List<V>>() { public List<V> get() { return Lists.newArrayListWithCapacity(expectedValuesPerKey); } }); }
From source file:org.eclipse.xtext.xbase.typesystem.util.Multimaps2.java
/** * Constructs an empty {@code ListMultimap} with enough capacity to hold the specified numbers of keys and values * without resizing. It uses a linked map internally. * //from w w w. j a v a2 s . c om * @param expectedKeys * the expected number of distinct keys * @param expectedValuesPerKey * the expected average number of values per key * @throws IllegalArgumentException * if {@code expectedKeys} or {@code expectedValuesPerKey} is negative */ public static <K, V> ListMultimap<K, V> newLinkedHashListMultimap(int expectedKeys, final int expectedValuesPerKey) { return Multimaps.newListMultimap(new LinkedHashMap<K, Collection<V>>(expectedKeys), new Supplier<List<V>>() { @Override public List<V> get() { return Lists.newArrayListWithCapacity(expectedValuesPerKey); } }); }
From source file:org.geoserver.ows.util.ClassProperties.java
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);/*w ww .ja v a2s .co m*/ 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; }
From source file:org.openqa.testing.HeaderContainer.java
protected HeaderContainer() { Map<String, Collection<String>> headersMap = Maps.newHashMap(); this.headers = Multimaps.newListMultimap(headersMap, Lists::newLinkedList); }
From source file:org.openqa.selenium.remote.server.testing.HeaderContainer.java
protected HeaderContainer() { Map<String, Collection<String>> headersMap = Maps.newHashMap(); this.headers = Multimaps.newListMultimap(headersMap, new Supplier<List<String>>() { public List<String> get() { return Lists.newLinkedList(); }/*w w w . ja v a 2 s . c o m*/ }); }
From source file:com.googlecode.clearnlp.util.UTGuava.java
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(); }/*from w ww. j ava 2s .c o m*/ }); return map; }
From source file:com.foundationdb.server.test.mt.util.TimeMarkerComparison.java
/** See {@link #combineTimeMarkers(TimeMarker...)}. */ static List<List<String>> combineTimeMarkers(Collection<TimeMarker> timeMarkers) { // Sort by time, list of lists of messages from all markers ListMultimap<Long, List<String>> timeToMarks = Multimaps .newListMultimap(new TreeMap<Long, Collection<List<String>>>(), new Supplier<List<List<String>>>() { @Override// w w w .j av a 2 s.c om public List<List<String>> get() { return new ArrayList<>(); } }); for (TimeMarker tm : timeMarkers) { for (Entry<Long, List<String>> entry : Multimaps.asMap(tm.getMarks()).entrySet()) { timeToMarks.put(entry.getKey(), entry.getValue()); } } // Concatenate into final ordering List<List<String>> output = new ArrayList<>(); for (List<List<String>> singleTimeMarks : Multimaps.asMap(timeToMarks).values()) { // Split a given Marker's messages apart, coalesce overlapping timestamps from multiple Marker's ListMultimap<Integer, String> split = ArrayListMultimap.create(); for (List<String> marks : singleTimeMarks) { for (int i = 0; i < marks.size(); ++i) { split.put(i, marks.get(i)); } } // Sort any coalesced and output for (List<String> marks : Multimaps.asMap(split).values()) { Collections.sort(marks); output.add(marks); } } return output; }