List of usage examples for com.google.common.collect Multimap put
boolean put(@Nullable K key, @Nullable V value);
From source file:eu.esdihumboldt.hale.common.core.report.ReportSession.java
/** * Add a {@link Report} to this session. * // w w w . j a v a 2 s. c o m * @param report the report */ @SuppressWarnings("unchecked") public <M extends Message, R extends Report<M>> void addReport(R report) { // get all reports for this messageType Multimap<Class<? extends Report<?>>, Report<?>> reportMap = getReports(report.getMessageType()); // add the report to temporary map reportMap.put((Class<? extends Report<?>>) report.getClass(), report); // add them to internal storage this.reports.put(report.getMessageType(), reportMap); }
From source file:org.basepom.mojo.duplicatefinder.classpath.ClasspathCacheElement.java
void putClasses(final Multimap<String, File> classMap, final Predicate<String> excludePredicate) { for (final String className : Collections2.filter(classes, Predicates.not(excludePredicate))) { classMap.put(className, element); }// w w w .j a v a2 s .c o m }
From source file:zeldaswordskills.item.ItemBrokenSword.java
@Override public Multimap getAttributeModifiers(ItemStack stack) { Multimap multimap = super.getAttributeModifiers(stack); multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", 2.0D, 0)); return multimap; }
From source file:br.com.caelum.vraptor.interceptor.multipart.MultipartItemsProcessor.java
public void process() { Multimap<String, String> params = LinkedListMultimap.create(); for (FileItem item : items) { if (item.isFormField()) { params.put(item.getFieldName(), getValue(item)); continue; }/*from w w w .jav a2 s . co m*/ if (notEmpty(item)) { try { UploadedFile fileInformation = new DefaultUploadedFile(item.getInputStream(), item.getName(), item.getContentType()); parameters.setParameter(item.getFieldName(), item.getName()); request.setAttribute(item.getName(), fileInformation); logger.debug("Uploaded file: {} with {}", item.getFieldName(), fileInformation); } catch (Exception e) { throw new InvalidParameterException("Cant parse uploaded file " + item.getName(), e); } } else { logger.debug("A file field was empty: {}", item.getFieldName()); } } for (String paramName : params.keySet()) { Collection<String> paramValues = params.get(paramName); parameters.setParameter(paramName, paramValues.toArray(new String[paramValues.size()])); } }
From source file:com.bazaarvoice.snitch.servlet.VariableServlet.java
@SuppressWarnings("unchecked") @Override//w ww . j a va 2s.c om protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException { addClientNoCacheHeaders(response); response.setContentType("application/json"); // Organize the variables into a multimap indexed by key Multimap<String, Variable> variables = HashMultimap.create(); for (Variable variable : _snitch.getVariables()) { variables.put(variable.getName(), variable); } JsonWriter writer = new JsonWriter(new BufferedWriter(response.getWriter())); writer.setIndent(" "); // Pretty print by default try { writer.beginObject(); for (String name : variables.keySet()) { Collection<Variable> vars = variables.get(name); writer.name(name); if (vars.size() > 1) { // Only render as an array if we have a name collision writer.beginArray(); } for (Variable variable : vars) { Formatter formatter = _snitch.getFormatter(variable); formatter.format(variable.getValue(), writer); } if (vars.size() > 1) { writer.endArray(); } } writer.endObject(); } finally { Closeables.closeQuietly(writer); } }
From source file:org.richfaces.resource.optimizer.resource.scan.impl.reflections.MarkerResourcesScanner.java
@Override public void scan(File file) { String relativePath = file.getRelativePath(); if (relativePath.startsWith(META_INF) && relativePath.endsWith(RESOURCE_PROPERTIES_EXT)) { Multimap<String, String> store = getStore(); String className = relativePath.substring(META_INF.length(), relativePath.length() - RESOURCE_PROPERTIES_EXT.length()); store.put(STORE_KEY, className); }// w w w. j a va 2 s . c o m }
From source file:com.facebook.buck.apple.clang.VFSOverlay.java
@JsonProperty("roots") private ImmutableList<VirtualDirectory> computeRoots() { Multimap<Path, Pair<Path, Path>> byParent = MultimapBuilder.hashKeys().hashSetValues().build(); overlays.forEach((virtual, real) -> { byParent.put(virtual.getParent(), new Pair<>(virtual.getFileName(), real)); });// ww w. ja v a 2s . c o m return byParent.asMap().entrySet().stream() .map(e -> new VirtualDirectory(e.getKey(), e.getValue().stream().map(x -> new VirtualFile(x.getFirst(), x.getSecond())) .collect(ImmutableList.toImmutableList()))) .collect(ImmutableList.toImmutableList()); }
From source file:org.basepom.mojo.duplicatefinder.classpath.ClasspathCacheElement.java
void putResources(final Multimap<String, File> resourceMap, final Predicate<String> excludePredicate) { for (final String resource : Collections2.filter(resources, Predicates.not(excludePredicate))) { resourceMap.put(resource, element); }//from www .j av a 2 s. c om }
From source file:de.tudarmstadt.ukp.dkpro.wsd.WSDUtils.java
/** * Read key-value pairs of the specified types from the specified columns of * a delimited text file into a Multimap. * * @param url//from www .j ava 2s. co m * Location of the file to read * @param keyColumn * The index of the column giving the keys * @param keyClass * The class of the key * @param valueColumn * The index of the column giving the values * @param valueClass * The class of the value * @param delimiterRegex * A regular expression for the field delimiter * @return A map of keys to values * @throws IOException * @throws IllegalArgumentException */ public static <K, V> Multimap<K, V> readMultimap(final URL url, final int keyColumn, final Class<K> keyClass, final int valueColumn, final Class<V> valueClass, final String delimiterRegex) throws IOException, IllegalArgumentException { Multimap<K, V> map = HashMultimap.create(); InputStream is = url.openStream(); String content = IOUtils.toString(is, "UTF-8"); BufferedReader br = new BufferedReader(new StringReader(content)); Constructor<K> keyConstructor; Constructor<V> valueConstructor; try { keyConstructor = keyClass.getConstructor(String.class); valueConstructor = valueClass.getConstructor(String.class); } catch (Exception e) { throw new IllegalArgumentException(e); } String line; String[] lineParts; while ((line = br.readLine()) != null) { lineParts = line.split(delimiterRegex); K key; V value; try { key = keyConstructor.newInstance(lineParts[keyColumn - 1]); value = valueConstructor.newInstance(lineParts[valueColumn - 1]); } catch (Exception e) { throw new IllegalArgumentException(e); } map.put(key, value); } return map; }
From source file:io.covert.dns.storage.accumulo.mutgen.EdgeMutationGeneratorFactory.java
@Override public MutationGenerator create(Configuration conf) throws Exception { Multimap<String, String> edges = HashMultimap.create(); for (String edge : conf.get("edge.mutation.generator.edges").split(",")) { String names[] = edge.split(":", 2); edges.put(names[0], names[1]); }//ww w .jav a 2s.c o m System.out.println(edges); return new EdgeMutationGenerator(conf.get("edge.mutation.generator.table"), conf.get("edge.mutation.generator.data.type"), edges, conf.getBoolean("edge.mutation.generator.bidirection", true), conf.getBoolean("edge.mutation.generator.univar.stats", true)); }