List of usage examples for com.google.common.collect ImmutableMultimap.Builder put
@Deprecated @Override public boolean put(K key, V value)
From source file:org.ambraproject.wombat.config.site.SiteSet.java
private static ImmutableMultimap<String, Site> groupByJournalKey(Set<Site> sites) { ImmutableMultimap.Builder<String, Site> builder = ImmutableMultimap.builder(); for (Site site : sites) { builder.put(site.getJournalKey(), site); }/*from w w w . j a v a 2 s . c o m*/ return builder.build(); }
From source file:google.registry.tools.EppToolCommand.java
/** * Helper function for grouping sets of domain names into respective TLDs. Useful for batched * EPP calls when invoking commands (i.e. domain check) with sets of domains across multiple TLDs. *///from w w w .j a v a 2 s . co m protected static Multimap<String, String> validateAndGroupDomainNamesByTld(List<String> names) { ImmutableMultimap.Builder<String, String> builder = new ImmutableMultimap.Builder<>(); for (String name : names) { InternetDomainName tld = findTldForNameOrThrow(InternetDomainName.from(name)); builder.put(tld.toString(), name); } return builder.build(); }
From source file:com.google.devtools.build.importdeps.ResolutionFailureChain.java
private static void getMissingClassesWithSubclasses(ClassInfo subclass, ImmutableList<ResolutionFailureChain> parentChains, ImmutableMultimap.Builder<String, ClassInfo> result) { for (ResolutionFailureChain parentChain : parentChains) { if (parentChain.resolutionStartClass() == null) { checkState(parentChain.parentChains().isEmpty() && parentChain.missingClasses().size() == 1); result.put(parentChain.missingClasses().get(0), subclass); } else {//w ww . jav a 2s. com checkState(!parentChain.parentChains().isEmpty()); getMissingClassesWithSubclasses(parentChain.resolutionStartClass(), parentChain.parentChains(), result); } } }
From source file:io.blobkeeper.server.util.MetadataParser.java
public static Multimap<String, String> getHeaders(@NotNull HttpRequest request) { checkNotNull(request, "request is required!"); Iterable<Map.Entry<String, String>> filtered = from(request.headers()) .filter(elt -> elt.getKey().startsWith("X-Metadata")); ImmutableMultimap.Builder<String, String> valueBuilder = ImmutableMultimap.builder(); for (Map.Entry<String, String> elt : filtered) { if (elt.getKey().equals(AUTH_TOKEN_HEADER)) { for (String accessToken : from(on(",").split(elt.getValue()))) { valueBuilder.put(elt.getKey(), accessToken); }// www . j a v a 2 s . c o m } else { valueBuilder.put(elt.getKey(), elt.getValue()); } } return valueBuilder.build(); }
From source file:com.google.idea.blaze.base.targetmaps.ReverseDependencyMap.java
public static ImmutableMultimap<TargetKey, TargetKey> createRdepsMap(TargetMap targetMap) { ImmutableMultimap.Builder<TargetKey, TargetKey> builder = ImmutableMultimap.builder(); for (TargetIdeInfo target : targetMap.targets()) { TargetKey key = target.key;//from w w w . j ava 2s. c om for (Dependency dep : target.dependencies) { TargetKey depKey = dep.targetKey; if (targetMap.contains(depKey)) { builder.put(depKey, key); } } } return builder.build(); }
From source file:me.lucko.luckperms.api.context.ImmutableContextSet.java
/** * Creates a ImmutableContextSet from an existing map * * @param map the map to copy from/*from w ww. ja va 2 s.co m*/ * @return a new ImmutableContextSet representing the pairs from the map * @throws NullPointerException if the map is null */ public static ImmutableContextSet fromMap(Map<String, String> map) { if (map == null) { throw new NullPointerException("map"); } ImmutableMultimap.Builder<String, String> b = ImmutableMultimap.builder(); for (Map.Entry<String, String> e : map.entrySet()) { b.put(e.getKey(), e.getValue()); } return new ImmutableContextSet(b.build()); }
From source file:com.google.caliper.runner.EnvironmentGetter.java
/** * Returns the key/value pairs from the specified properties-file like file. * Unlike standard Java properties files, {@code reader} is allowed to list * the same property multiple times. Comments etc. are unsupported. * * <p>If there's any problem reading the file's contents, we'll return an * empty Multimap.//from w ww . jav a 2 s. c o m */ private static Multimap<String, String> propertiesFromLinuxFile(String file) { try { List<String> lines = Files.readLines(new File(file), Charset.defaultCharset()); ImmutableMultimap.Builder<String, String> result = ImmutableMultimap.builder(); for (String line : lines) { // TODO(schmoe): replace with Splitter (in Guava release 10) String[] parts = line.split("\\s*\\:\\s*", 2); if (parts.length == 2) { result.put(parts[0], parts[1]); } } return result.build(); } catch (IOException e) { // If there's any problem reading the file, just return an empty multimap. return ImmutableMultimap.of(); } }
From source file:com.google.caliper.EnvironmentGetter.java
/** * Returns the key/value pairs from the specified properties-file like * reader. Unlike standard Java properties files, {@code reader} is allowed * to list the same property multiple times. Comments etc. are unsupported. *///from w ww . j a v a2 s . co m private static Multimap<String, String> propertiesFileToMultimap(Reader reader) throws IOException { ImmutableMultimap.Builder<String, String> result = ImmutableMultimap.builder(); BufferedReader in = new BufferedReader(reader); String line; while ((line = in.readLine()) != null) { String[] parts = line.split("\\s*\\:\\s*", 2); if (parts.length == 2) { result.put(parts[0], parts[1]); } } in.close(); return result.build(); }
From source file:com.google.idea.blaze.base.rulemaps.ReverseDependencyMap.java
public static ImmutableMultimap<Label, Label> createRdepsMap(Map<Label, RuleIdeInfo> ruleMap) { ImmutableMultimap.Builder<Label, Label> builder = ImmutableMultimap.builder(); for (Map.Entry<Label, RuleIdeInfo> entry : ruleMap.entrySet()) { Label label = entry.getKey(); RuleIdeInfo ruleIdeInfo = entry.getValue(); for (Label dep : Iterables.concat(ruleIdeInfo.dependencies, ruleIdeInfo.runtimeDeps)) { if (ruleMap.containsKey(dep)) { builder.put(dep, label); }/*from w w w . j a v a 2 s. com*/ } } return builder.build(); }
From source file:org.tensorics.core.tensor.Positions.java
public static Multimap<Position, Position> mapByStripping(Iterable<Position> positions, Set<Class<?>> dimensionsToStrip) { DimensionStripper stripper = stripping(dimensionsToStrip); ImmutableMultimap.Builder<Position, Position> builder = ImmutableMultimap.builder(); for (Position position : positions) { builder.put(stripper.apply(position), position); }/* w ww.jav a 2s . c om*/ return builder.build(); }