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:com.google.api.client.discovery.RestDiscovery.java
/** * Returns a list of the methods in this API. */// www. jav a2 s . c om public Map<String, RestMethod> getMethods() { if (document.getMethods() == null) { return Collections.emptyMap(); } return Maps.transformValues(document.getMethods(), new Function<Restmethod, RestMethod>() { public RestMethod apply(Restmethod input) { return new RestMethod(document.getSchemas(), input); } }); }
From source file:com.google.gerrit.metrics.dropwizard.BucketedHistogram.java
@Override public Map<Object, Metric> getCells() { return Maps.transformValues(cells, h -> h.metric); }
From source file:eu.esdihumboldt.hale.common.align.io.impl.internal.AlignmentBean.java
/** * Create a bean for the given alignment * //w ww. j a va 2 s . c o m * @param alignment the alignment * @param pathUpdate to update relative paths in case of a path change */ public AlignmentBean(Alignment alignment, final PathUpdate pathUpdate) { super(); base = new HashMap<String, URI>( Maps.transformValues(alignment.getBaseAlignments(), new Function<URI, URI>() { @Override public URI apply(URI input) { return pathUpdate.findLocation(input, true, false, true); } })); // populate bean from alignment for (Cell cell : alignment.getCells()) { generateModifier(cell); if (cell instanceof BaseAlignmentCell) continue; CellBean cellBean = new CellBean(cell); cells.add(cellBean); } }
From source file:org.sonar.server.computation.task.projectanalysis.component.VisitorsCrawler.java
public Map<ComponentVisitor, Long> getCumulativeDurations() { if (computeDuration) { return ImmutableMap.copyOf( Maps.transformValues(this.visitorCumulativeDurations, VisitorDurationToDuration.INSTANCE)); }/*from w w w . j a va 2 s .com*/ return Collections.emptyMap(); }
From source file:com.google.gerrit.metrics.dropwizard.BucketedCounter.java
@Override public Map<Object, Metric> getCells() { return Maps.transformValues(cells, c -> c.metric); }
From source file:org.jclouds.rest.config.BindPropertiesToAnnotations.java
@Provides @Singleton// w ww . j a va 2s .c o m @Named("TIMEOUTS") protected Map<String, Long> timeouts( Function<Predicate<String>, Map<String, String>> filterStringsBoundByName) { Map<String, String> stringBoundWithTimeoutPrefix = filterStringsBoundByName.apply(new Predicate<String>() { @Override public boolean apply(String input) { return input.startsWith(PROPERTY_TIMEOUTS_PREFIX); } }); Map<String, Long> longsByName = Maps.transformValues(stringBoundWithTimeoutPrefix, new Function<String, Long>() { @Override public Long apply(String input) { return Long.valueOf(String.valueOf(input)); } }); return Maps2.transformKeys(longsByName, new Function<String, String>() { @Override public String apply(String input) { return input.replaceFirst(PROPERTY_TIMEOUTS_PREFIX, ""); } }); }
From source file:co.cask.cdap.data2.dataset2.lib.table.leveldb.LevelDBMetricsTable.java
@Override public void put(NavigableMap<byte[], NavigableMap<byte[], Long>> updates) { NavigableMap<byte[], NavigableMap<byte[], byte[]>> convertedUpdates = Maps.transformValues(updates, TRANSFORM_MAP_LONG_TO_BYTE_ARRAY); try {// w w w . j a va 2 s.c o m core.persist(convertedUpdates, System.currentTimeMillis()); } catch (IOException e) { throw new DataSetException("Put failed on table " + tableName, e); } }
From source file:com.opengamma.master.organization.impl.MasterOrganizationSource.java
@Override public Map<UniqueId, Organization> get(Collection<UniqueId> uniqueIds) { Map<UniqueId, OrganizationDocument> documents = getMaster().get(uniqueIds); return Maps.transformValues(documents, new Function<OrganizationDocument, Organization>() { @Override/*from www . j a v a 2 s.c o m*/ public Organization apply(OrganizationDocument organizationDocument) { return organizationDocument.getOrganization(); } }); }
From source file:com.fatboyindustrial.firestarter.VmConfig.java
/** * Creates a VM config from the given HOCON configuration. * @param name The configuration name./*w w w .ja va2 s. co m*/ * @param vmConfig The configuration. * @return The VM config. * @throws IllegalArgumentException If the configuration is invalid. */ public static VmConfig fromConfig(final String name, final Config vmConfig) throws IllegalArgumentException { Preconditions.checkNotNull(name, "name cannot be null"); Preconditions.checkNotNull(vmConfig, "vmConfig cannot be null"); return new VmConfig(name, (int) (vmConfig.getBytes("heap") / MEGABYTES), vmConfig.getString("jar"), vmConfig.getStringList("args"), vmConfig.hasPath("properties") ? Maps.transformValues(vmConfig.getObject("properties").unwrapped(), String::valueOf) : ImmutableMap.of()); }
From source file:org.grouplens.lenskit.eval.graph.GraphWriter.java
private void putAttributes(Map<String, Object> attrs) throws IOException { if (!attrs.isEmpty()) { output.append(" ["); Joiner.on(", ").withKeyValueSeparator("=").appendTo(output, Maps.transformValues(attrs, new Function<Object, String>() { @Nullable/*from w w w . j ava 2s . c o m*/ @Override public String apply(@Nullable Object input) { return safeValue(input); } })); output.append("]"); } }