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:ddf.camel.component.catalog.content.ContentProducerDataAccessObject.java
protected HashMap<String, Serializable> getProperties(Map<String, Object> headers) { return Maps.newHashMap(Maps.transformValues(headers, Serializable.class::cast)); }
From source file:brooklyn.config.BrooklynProperties.java
@SuppressWarnings("unchecked") public BrooklynProperties addFrom(Map map) { putAll(Maps.transformValues(map, StringFunctions.trim())); return this; }
From source file:ninja.leaping.permissionsex.backend.memory.MemoryOptionSubjectData.java
@Override public Map<Set<Entry<String, String>>, Map<String, Integer>> getAllPermissions() { return Maps.filterValues(Maps.transformValues(contexts, new Function<DataEntry, Map<String, Integer>>() { @Nullable//from www . j ava 2s . c o m @Override public Map<String, Integer> apply(@Nullable DataEntry dataEntry) { return dataEntry == null ? null : dataEntry.permissions; } }), Predicates.notNull()); }
From source file:org.opendaylight.controller.netconf.test.tool.NetconfDeviceSimulator.java
private Map<ModuleBuilder, String> toModuleBuilders( final Map<SourceIdentifier, Map.Entry<ASTSchemaSource, YangTextSchemaSource>> sources) { final Map<SourceIdentifier, ParserRuleContext> asts = Maps.transformValues(sources, new Function<Map.Entry<ASTSchemaSource, YangTextSchemaSource>, ParserRuleContext>() { @Override// w w w . j a v a 2 s. c o m public ParserRuleContext apply(final Map.Entry<ASTSchemaSource, YangTextSchemaSource> input) { return input.getKey().getAST(); } }); final Map<String, TreeMap<Date, URI>> namespaceContext = BuilderUtils .createYangNamespaceContext(asts.values(), Optional.<SchemaContext>absent()); final ParseTreeWalker walker = new ParseTreeWalker(); final Map<ModuleBuilder, String> sourceToBuilder = new HashMap<>(); for (final Map.Entry<SourceIdentifier, ParserRuleContext> entry : asts.entrySet()) { final ModuleBuilder moduleBuilder = YangParserListenerImpl .create(namespaceContext, entry.getKey().getName(), walker, entry.getValue()) .getModuleBuilder(); try (InputStreamReader stream = new InputStreamReader( sources.get(entry.getKey()).getValue().openStream(), Charsets.UTF_8)) { sourceToBuilder.put(moduleBuilder, CharStreams.toString(stream)); } catch (final IOException e) { throw new RuntimeException(e); } } return sourceToBuilder; }
From source file:com.facebook.buck.cxx.CxxBuckConfig.java
public ImmutableMap<String, Flavor> getDefaultFlavorsForRuleType(BuildRuleType type) { return ImmutableMap.copyOf(Maps.transformValues(delegate.getEntriesForSection("defaults." + type.getName()), ImmutableFlavor::of));//ww w.j a v a 2s . c om }
From source file:com.google.devtools.build.skyframe.AbstractSkyFunctionEnvironment.java
@Override public <E extends Exception> Map<SkyKey, ValueOrException<E>> getValuesOrThrow(Iterable<SkyKey> depKeys, Class<E> exceptionClass) throws InterruptedException { return Maps.transformValues(getValuesOrThrow(depKeys, exceptionClass, BottomException.class), makeSafeDowncastToVOEFunction(exceptionClass)); }
From source file:edu.harvard.med.screensaver.service.libraries.PlateUpdater.java
@Transactional public void updatePrimaryPlateConcentrations(Copy copy) { ConcentrationStatistics concentrationStatistics = new ConcentrationStatistics(); copy.setConcentrationStatistics(concentrationStatistics); // update the plates using values from the wells Collection<Plate> platesToConsider = Sets.newHashSet(copy.getPlates().values()); for (Iterator<Plate> iter = platesToConsider.iterator(); iter.hasNext();) { Plate p = iter.next();//from www . jav a 2s . c o m p.setConcentrationStatistics(new ConcentrationStatistics()); updatePrimaryWellConcentration(p); // update the copy with the values from the plate if (p.getMaxMgMlConcentration() != null) { if (concentrationStatistics.getMaxMgMlConcentration() == null) concentrationStatistics.setMaxMgMlConcentration(p.getMaxMgMlConcentration()); else if (p.getMaxMgMlConcentration() .compareTo(concentrationStatistics.getMaxMgMlConcentration()) > 0) concentrationStatistics.setMaxMgMlConcentration(p.getMaxMgMlConcentration()); if (concentrationStatistics.getMinMgMlConcentration() == null) concentrationStatistics.setMinMgMlConcentration(p.getMinMgMlConcentration()); else if (p.getMinMgMlConcentration() .compareTo(concentrationStatistics.getMinMgMlConcentration()) < 0) concentrationStatistics.setMinMgMlConcentration(p.getMinMgMlConcentration()); } if (p.getMaxMolarConcentration() != null) { if (concentrationStatistics.getMaxMolarConcentration() == null) concentrationStatistics.setMaxMolarConcentration(p.getMaxMolarConcentration()); else if (p.getMaxMolarConcentration() .compareTo(concentrationStatistics.getMaxMolarConcentration()) > 0) concentrationStatistics.setMaxMolarConcentration(p.getMaxMolarConcentration()); if (concentrationStatistics.getMinMolarConcentration() == null) concentrationStatistics.setMinMolarConcentration(p.getMinMolarConcentration()); else if (p.getMinMolarConcentration() .compareTo(concentrationStatistics.getMinMolarConcentration()) < 0) concentrationStatistics.setMinMolarConcentration(p.getMinMolarConcentration()); } if (!isStoredAtFacility.apply(p.getStatus())) // consider only plates stored at this facility { iter.remove(); continue; } } Map<BigDecimal, Integer> mgMlCounts = Maps .transformValues( Multimaps.index( Lists.newArrayList(Iterators.filter(platesToConsider.iterator(), Predicates.compose(Predicates.notNull(), Plate.ToPrimaryWellMgMlConcentration))), Plate.ToPrimaryWellMgMlConcentration).asMap(), CollectionSize); if (!mgMlCounts.isEmpty()) concentrationStatistics.setPrimaryWellMgMlConcentration(findMaxByValueThenKey(mgMlCounts).getKey()); Map<MolarConcentration, Integer> molarCounts = Maps .transformValues( Multimaps.index( Lists.newArrayList(Iterators.filter(platesToConsider.iterator(), Predicates.compose(Predicates.notNull(), Plate.ToPrimaryWellMolarConcentration))), Plate.ToPrimaryWellMolarConcentration).asMap(), CollectionSize); if (!molarCounts.isEmpty()) concentrationStatistics.setPrimaryWellMolarConcentration(findMaxByValueThenKey(molarCounts).getKey()); }
From source file:org.apache.metron.stellar.common.shell.StellarExecutor.java
/** * Executes the Stellar expression and returns the result. * @param expression The Stellar expression to execute. * @return The result of the expression. *///from w w w . j av a 2 s .c om public Object execute(String expression) { VariableResolver variableResolver = new MapVariableResolver( Maps.transformValues(variables, result -> result.getResult()), Collections.emptyMap()); StellarProcessor processor = new StellarProcessor(); return processor.parse(expression, variableResolver, functionResolver, context); }
From source file:org.jclouds.joyent.cloudapi.v6_5.domain.Machine.java
/** * /* w ww. ja v a 2 s . c o m*/ * <h4>note</h4> * * If the value is a string, it will be quoted, as that's how json strings are represented. * * @return key to a json literal of the value * @see Metadata#valueType * @see Json#fromJson */ public Map<String, String> getMetadataAsJsonLiterals() { return Maps.transformValues(metadata, Functions.toStringFunction()); }
From source file:ninja.leaping.permissionsex.backend.sql.SqlSubjectData.java
@Override public ImmutableSubjectData clearParents() { if (this.segments.isEmpty()) { return this; }/* w ww.ja va 2 s. c o m*/ Map<Set<Entry<String, String>>, Segment> newValue = Maps.transformValues(this.segments, dataEntry -> dataEntry == null ? null : dataEntry.withoutParents()); return newWithUpdate(newValue, createBulkUpdateFunc(newValue.keySet())); }