List of usage examples for com.google.common.collect Multimap keySet
Set<K> keySet();
From source file:eu.numberfour.n4js.ui.organize.imports.N4JSOrganizeImportsHelper.java
/** * Turn this Multimap into a two-dimensional array the first index giving the page, second the choices of this page. * * @param multimap//from w w w. ja v a2s . c o m * name to many options * @return two-dim Array of T */ public static <T> Object[][] createOptions(Multimap<String, T> multimap) { Object[][] ret = new Object[multimap.keySet().size()][]; int page = 0; for (String key : multimap.keySet()) { Collection<T> values = multimap.get(key); ret[page] = new Object[values.size()]; int option = 0; for (T ns : values) { ret[page][option] = ns; option++; } page++; } return ret; }
From source file:org.eclipse.xtext.xbase.typesystem.util.Multimaps2.java
/** * Constructs an {@code ArrayListMultimap} with the same mappings as the specified multimap. It uses a linked map * internally../*w w w . j a v a 2 s. c o m*/ * * @param multimap * the multimap whose contents are copied to this multimap */ public static <K, V> ListMultimap<K, V> newLinkedHashListMultimap(Multimap<K, V> multimap) { int keySetSize = multimap.keySet().size(); int expectedKeys = Math.max(keySetSize, 2); ListMultimap<K, V> result = newLinkedHashListMultimap(expectedKeys, Math.max(3, multimap.size() / expectedKeys)); result.putAll(multimap); return result; }
From source file:org.icgc.dcc.portal.manifest.writer.PDCManifestWriter.java
@SneakyThrows public static void write(OutputStream buffer, Multimap<String, ManifestFile> bundles) { val urls = bundles.keySet(); val writer = new OutputStreamWriter(buffer, UTF_8); writer.write(createManifest(urls));//from w ww. ja v a 2s . co m writer.flush(); }
From source file:org.jclouds.occi.util.HeaderConverter.java
@IgnoreJRERequirement public static Headers convertHeaders(Multimap<String, String> googleHeaders) { Headers javaHeaders = new Headers(); for (String key : googleHeaders.keySet()) { for (String value : googleHeaders.get(key)) { javaHeaders.add(key, value); }/*ww w . j a va 2 s.c om*/ } return javaHeaders; }
From source file:org.terasology.documentation.BindingScraper.java
private static InputCategory findCategory(Multimap<InputCategory, String> categories, String id) { for (InputCategory x : categories.keySet()) { if (x.id().equals(id)) { return x; }/*from w w w . j ava2 s.c om*/ } return null; }
From source file:org.terasology.documentation.BindingScraper.java
private static InputCategory findEntry(Multimap<InputCategory, String> categories, String id) { for (InputCategory x : categories.keySet()) { if (categories.get(x).contains(id)) { return x; }/*from w w w . j av a2 s . co m*/ } return null; }
From source file:org.apache.shindig.gadgets.FetchResponseUtils.java
private static void addAllHeaders(Map<String, Collection<String>> headers, HttpResponse response) { Multimap<String, String> responseHeaders = response.getHeaders(); for (String name : responseHeaders.keySet()) { headers.put(name.toLowerCase(), responseHeaders.get(name)); }// www .j ava 2 s.c o m }
From source file:org.jclouds.openstack.nova.v1_1.util.NovaUtils.java
/** * The traditional way to represent a graph in Java is Map<V, Set<V>>, which is awkward in a * number of ways. Guava's Multimap framework makes it easy to handle a mapping from keys to * multiple values.//from ww w . j a v a 2 s .com * <p/> * Until we write or discover a gson Multimap deserializer, we may be stuck with this. * * TODO: ask on stackoverflow and/or jesse wilson */ @Deprecated public static <K, V> Map<K, Set<V>> toOldSchool(Multimap<K, V> in) { ImmutableMap.Builder<K, Set<V>> out = ImmutableMap.<K, Set<V>>builder(); for (K type : in.keySet()) out.put(type, ImmutableSet.copyOf(in.get(type))); return out.build(); }
From source file:be.solidx.hot.utils.CollectionUtils.java
public static Map<String, Object> flat(Multimap<String, Object> multimap) { Map<String, Object> flattenMap = new LinkedHashMap<String, Object>(); for (String key : multimap.keySet()) { int i = 0; for (Object object : multimap.get(key)) { flattenMap.put(key.replaceAll("\\.", "_") + "_" + i++, object); }/* www .ja v a 2 s . c o m*/ } return flattenMap; }
From source file:org.icgc.dcc.portal.manifest.writer.GenericManifestWriter.java
@SneakyThrows public static void write(OutputStream buffer, Multimap<String, ManifestFile> bundles) { val tsv = createTsv(buffer); tsv.writeHeader(TSV_HEADERS);//from w ww. j av a 2 s. c o m for (val url : bundles.keySet()) { val bundle = bundles.get(url); val row = createRow(url, bundle); tsv.write(row); } tsv.flush(); }