List of usage examples for com.google.common.collect ImmutableMultimap.Builder putAll
@Deprecated @Override public boolean putAll(K key, Iterable<? extends V> values)
From source file:org.lanternpowered.server.asset.AbstractMultiAssetRepository.java
@Override public Multimap<String, Asset> getAssetsMap(String path, boolean checkChildDirectories) { final Map<String, Map<String, Asset>> map = new HashMap<>(); for (AssetRepository repository : getRepositories()) { final Multimap<String, Asset> multimap = repository.getAssetsMap(path, checkChildDirectories); multimap.entries().forEach(entry -> { final Map<String, Asset> entries = map.computeIfAbsent(entry.getKey(), key -> new HashMap<>()); entries.putIfAbsent(entry.getValue().getId(), entry.getValue()); });/*from www . ja v a2 s .c o m*/ } final ImmutableMultimap.Builder<String, Asset> builder = ImmutableMultimap.builder(); map.entrySet().forEach(entry -> builder.putAll(entry.getKey(), entry.getValue().values())); return builder.build(); }
From source file:org.apache.twill.internal.json.ArgumentsCodec.java
@Override public Arguments deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); List<String> arguments = context.deserialize(jsonObj.get("arguments"), new TypeToken<List<String>>() { }.getType());/*from w w w . ja va 2 s . co m*/ Map<String, Collection<String>> args = context.deserialize(jsonObj.get("runnableArguments"), new TypeToken<Map<String, Collection<String>>>() { }.getType()); ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder(); for (Map.Entry<String, Collection<String>> entry : args.entrySet()) { builder.putAll(entry.getKey(), entry.getValue()); } return new Arguments(arguments, builder.build()); }
From source file:com.github.tomakehurst.wiremock.http.HttpHeaders.java
public HttpHeaders(Iterable<HttpHeader> headers) { ImmutableMultimap.Builder<CaseInsensitiveKey, String> builder = ImmutableMultimap.builder(); for (HttpHeader header : headers) { builder.putAll(caseInsensitive(header.key()), header.values()); }/*from ww w. j a va 2s. c o m*/ this.headers = builder.build(); }
From source file:org.javersion.store.jdbc.DocumentVersionStoreJdbc.java
public void append(Id docId, Iterable<VersionNode<PropertyPath, Object, M>> versions) { options.transactions.writeRequired(() -> { ImmutableMultimap.Builder<Id, VersionNode<PropertyPath, Object, M>> builder = ImmutableMultimap .builder();//from www . ja v a 2s . com doAppend(builder.putAll(docId, versions).build()); return null; }); }
From source file:co.cask.cdap.data.stream.service.InMemoryStreamMetaStore.java
@Override public synchronized Multimap<Id.Namespace, StreamSpecification> listStreams() throws Exception { ImmutableMultimap.Builder<Id.Namespace, StreamSpecification> builder = ImmutableMultimap.builder(); for (String namespaceId : streams.keySet()) { synchronized (streams) { Collection<String> streamNames = streams.get(namespaceId); builder.putAll(Id.Namespace.from(namespaceId), Collections2.transform(streamNames, new Function<String, StreamSpecification>() { @Nullable// www . ja v a 2s. com @Override public StreamSpecification apply(String input) { return new StreamSpecification.Builder().setName(input).create(); } })); } } return builder.build(); }
From source file:com.facebook.buck.android.SmartDexingStep.java
/** * @param primaryOutputPath Path for the primary dex artifact. * @param primaryInputsToDex Set of paths to include as inputs for the primary dex artifact. * @param secondaryOutputDir Directory path for the secondary dex artifacts, if there are any. * Note that this directory will be pruned such that only those secondary outputs generated * by this command will remain in the directory! * @param secondaryInputsToDex List of paths to input jar files, to use as dx input, keyed by the * corresponding output dex file./*from w w w . j av a 2s . c o m*/ * Note that for each output file (key), a separate dx invocation will be started with the * corresponding jar files (value) as the input. * @param successDir Directory where success artifacts are written. * @param numThreads Number of threads to use when invoking dx commands. If absent, a * reasonable default will be selected based on the number of available processors. */ public SmartDexingStep(final Path primaryOutputPath, final Supplier<Set<Path>> primaryInputsToDex, Optional<Path> secondaryOutputDir, final Optional<Supplier<Multimap<Path, Path>>> secondaryInputsToDex, DexInputHashesProvider dexInputHashesProvider, Path successDir, Optional<Integer> numThreads, EnumSet<Option> dxOptions) { this.outputToInputsSupplier = Suppliers.memoize(new Supplier<Multimap<Path, Path>>() { @Override public Multimap<Path, Path> get() { final ImmutableMultimap.Builder<Path, Path> map = ImmutableMultimap.builder(); map.putAll(primaryOutputPath, primaryInputsToDex.get()); if (secondaryInputsToDex.isPresent()) { map.putAll(secondaryInputsToDex.get().get()); } return map.build(); } }); this.secondaryOutputDir = Preconditions.checkNotNull(secondaryOutputDir); this.dexInputHashesProvider = Preconditions.checkNotNull(dexInputHashesProvider); this.successDir = Preconditions.checkNotNull(successDir); this.numThreads = Preconditions.checkNotNull(numThreads); this.dxOptions = Preconditions.checkNotNull(dxOptions); }
From source file:co.paralleluniverse.comsat.webactors.undertow.HttpRequestWrapper.java
@Override public Multimap<String, String> getParameters() { if (params == null) { final ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder(); final Map<String, Deque<String>> parameters = xch.getQueryParameters(); for (final String k : parameters.keySet()) builder.putAll(k, parameters.get(k)); params = builder.build();//from ww w . j a v a 2 s.co m } return params; }
From source file:org.prebake.core.GlobSet.java
private void groupByPrefixInto(PrefixTree t, ImmutableMultimap.Builder<String, Glob> out, StringBuilder prefix) {/*from w w w .j av a2s . c o m*/ Collection<Glob> globs = t.globsByExtension.values(); if (!globs.isEmpty()) { out.putAll(prefix.toString(), globs); } if (!t.children.isEmpty()) { int len = prefix.length(); for (Map.Entry<String, PrefixTree> child : t.children.entrySet()) { if (len != 0) { prefix.append('/'); } groupByPrefixInto(child.getValue(), out, prefix.append(child.getKey())); prefix.setLength(len); } } }
From source file:com.hippo.leveldb.impl.Version.java
public Multimap<Integer, FileMetaData> getFiles() { ImmutableMultimap.Builder<Integer, FileMetaData> builder = ImmutableMultimap.builder(); builder = builder.orderKeysBy(natural()); builder.putAll(0, level0.getFiles()); for (Level level : levels) { builder.putAll(level.getLevelNumber(), level.getFiles()); }//from w ww. ja va 2 s . c o m return builder.build(); }
From source file:com.google.devtools.build.lib.skyframe.serialization.MultimapCodec.java
@Override public ImmutableMultimap<K, V> deserialize(DeserializationContext context, CodedInputStream codedIn) throws SerializationException, IOException { ImmutableMultimap.Builder<K, V> result; if (codedIn.readBool()) { result = ImmutableListMultimap.builder(); } else {//from w w w .j a va 2s . co m result = ImmutableSetMultimap.builder(); } int length = codedIn.readInt32(); for (int i = 0; i < length; i++) { K key = context.deserialize(codedIn); Collection<V> values = context.deserialize(codedIn); result.putAll(key, values); } return result.build(); }