List of usage examples for com.google.common.collect Maps transformValues
@GwtIncompatible("NavigableMap") public static <K, V1, V2> NavigableMap<K, V2> transformValues(NavigableMap<K, V1> fromMap, Function<? super V1, V2> function)
From source file:org.jclouds.cloudloadbalancers.location.RegionUrisFromPropertiesAndAccountIDPathSuffix.java
@Override public Map<String, Supplier<URI>> get() { return Maps.transformValues(super.get(), filter); }
From source file:com.facebook.buck.android.toolchain.ndk.AbstractNdkCxxPlatformsProvider.java
/** @return all resolved {@link NdkCxxPlatform}s by {@link TargetCpuType}. */ public ImmutableMap<TargetCpuType, NdkCxxPlatform> getResolvedNdkCxxPlatforms(BuildRuleResolver resolver) { return ImmutableMap.copyOf(Maps.transformValues(getNdkCxxPlatforms(), platform -> Objects.requireNonNull(platform).resolve(resolver))); }
From source file:io.fabric8.process.fabric.child.tasks.ApplyConfigurationTask.java
@Override public void install(ProcessConfig config, String id, File installDir) throws Exception { Map<String, String> templates = Maps.filterKeys(configuration, isTemplate); Map<String, String> plainFiles = Maps.difference(configuration, templates).entriesOnlyOnLeft(); Map<String, String> renderedTemplates = Maps.transformValues(templates, new MvelTemplateRendering(variables)); File baseDir = ProcessUtils.findInstallDir(installDir); applyTemplates(renderedTemplates, baseDir); applyPlainConfiguration(plainFiles, baseDir); }
From source file:com.prealpha.minelib.nbt.CompoundTag.java
@Override public ByteBuffer toBytes() { // make copies to avoid encoding twice Map<String, ByteBuffer> nameBytes = ImmutableMap .copyOf(Maps.transformEntries(value, new EntryTransformer<String, Tag, ByteBuffer>() { @Override/* w ww .j a v a 2s.c o m*/ public ByteBuffer transformEntry(String key, Tag value) { return new StringTag(key).toBytes(); } })); Map<String, ByteBuffer> payloadBytes = ImmutableMap.copyOf(Maps.transformValues(value, Tag.ENCODER)); int length = 1; // for the null terminating byte for (ByteBuffer buffer : nameBytes.values()) { length += buffer.capacity() + 1; // add one for the tagType } for (ByteBuffer buffer : payloadBytes.values()) { length += buffer.capacity(); } ByteBuffer payload = ByteBuffer.allocate(length); for (String name : value.keySet()) { payload.put(value.get(name).getTagType().getBinaryType()); payload.put(nameBytes.get(name)); payload.put(payloadBytes.get(name)); } payload.put((byte) 0x00); payload.position(0); return payload; }
From source file:com.googlecode.jmxtrans.model.results.ResultValuesTransformer.java
@Nullable @Override/* www . j a v a 2 s. c om*/ public Result apply(@Nullable Result input) { if (input == null) { return null; } return new Result(input.getEpoch(), input.getAttributeName(), input.getClassName(), input.getObjDomain(), input.getKeyAlias(), input.getTypeName(), Maps.transformValues(input.getValues(), valueTransformer)); }
From source file:gobblin.metrics.reporter.RecursiveScheduledMetricReporter.java
public void reportRegistry(MetricRegistry registry) { Map<String, String> tags = Maps.newHashMap(); if (registry instanceof MetricContext) { tags = Maps.transformValues(((MetricContext) registry).getTagMap(), new Function<Object, String>() { @Override/*from www . j a v a 2 s . c o m*/ public String apply(Object input) { return input.toString(); } }); } report(registry.getGauges(this.filter), registry.getCounters(this.filter), registry.getHistograms(this.filter), registry.getMeters(this.filter), registry.getTimers(this.filter), tags); }
From source file:zotmc.collect.FluentMap.java
public <W> FluentMap<K, W> commuteValues(final Commuter<V, W> function) { final Map<K, W> delegatee = Maps.transformValues(delegatee(), function); return from(new DelegateMap<K, W>() { @Override/* ww w . jav a2 s. c om*/ protected Map<K, W> delegatee() { return delegatee; } @Override public W put(K key, W value) { try { return function.apply(FluentMap.this.delegatee().put(key, function.disapply(value))); } catch (ReverseOperationException e) { throw new IllegalArgumentException(e); } } }); }
From source file:ai.grakn.graql.internal.printer.HALPrinter.java
@Override public Json graqlString(boolean inner, Map<?, ?> map) { return Json.make(Maps.transformValues(map, value -> graqlString(true, value))); }
From source file:org.chaston.oakfunds.storage.mgmt.SchemaBuilder.java
@Inject SchemaBuilder(Set<RecordType> recordTypes, Set<FunctionDef> functionDefs) { Multimap<RecordType, RecordType> typesBySuperType = groupBySuperType(recordTypes); Map<String, TableDef.Builder> tableDefBuilders = createBaseTables(typesBySuperType); tableDefs = ImmutableMap//ww w. ja v a2 s.c o m .copyOf(Maps.transformValues(tableDefBuilders, new Function<TableDef.Builder, TableDef>() { @Override public TableDef apply(TableDef.Builder builder) { return builder.build(); } })); ImmutableMap.Builder<String, FunctionDef> functionDefsBuilder = ImmutableMap.builder(); for (FunctionDef functionDef : functionDefs) { functionDefsBuilder.put(functionDef.getName(), functionDef); } this.functionDefs = functionDefsBuilder.build(); }
From source file:net.derquinse.common.util.zip.LoadedZipFile.java
/** * Transform the entry map./*from ww w .j av a2s. c o m*/ */ private <T> Map<String, T> transform(Function<? super MemoryByteSource, T> f) throws IOException { try { return ImmutableMap.copyOf(Maps.transformValues(entryMap, f)); } catch (UncheckedExecutionException e) { Throwable t = e.getCause(); if (t instanceof IOException) { throw (IOException) t; } throw e; } }