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:edu.cmu.lti.oaqa.cse.space.uima.list.ExperimentBuilder.java
private static void appendMethodSignature(StringBuilder sb, Map<String, Object> tuples) { Map<String, String> ftuples = Maps.transformValues(tuples, new ObjectFormatter()); sb.append("["); Joiner.MapJoiner joiner = Joiner.on("#").withKeyValueSeparator(":"); joiner.appendTo(sb, ftuples);//from ww w.ja v a 2s. c o m sb.append("]"); }
From source file:com.facebook.buck.parser.PythonDslProjectBuildFileParser.java
private static Map<String, Object> convertSelectableAttributes(Map<String, Object> values) { return Maps.transformValues(values, PythonDslProjectBuildFileParser::convertToSelectableAttributeIfNeeded); }
From source file:com.google.gcloud.bigquery.QueryJobConfiguration.java
@Override com.google.api.services.bigquery.model.JobConfiguration toPb() { com.google.api.services.bigquery.model.JobConfiguration configurationPb = new com.google.api.services.bigquery.model.JobConfiguration(); JobConfigurationQuery queryConfigurationPb = new JobConfigurationQuery(); queryConfigurationPb.setQuery(query); configurationPb.setDryRun(dryRun()); if (allowLargeResults != null) { queryConfigurationPb.setAllowLargeResults(allowLargeResults); }/* w w w.ja va2 s.co m*/ if (createDisposition != null) { queryConfigurationPb.setCreateDisposition(createDisposition.toString()); } if (destinationTable != null) { queryConfigurationPb.setDestinationTable(destinationTable.toPb()); } if (defaultDataset != null) { queryConfigurationPb.setDefaultDataset(defaultDataset.toPb()); } if (flattenResults != null) { queryConfigurationPb.setFlattenResults(flattenResults); } if (priority != null) { queryConfigurationPb.setPriority(priority.toString()); } if (tableDefinitions != null) { queryConfigurationPb.setTableDefinitions( Maps.transformValues(tableDefinitions, ExternalTableDefinition.TO_EXTERNAL_DATA_FUNCTION)); } if (useQueryCache != null) { queryConfigurationPb.setUseQueryCache(useQueryCache); } if (userDefinedFunctions != null) { queryConfigurationPb.setUserDefinedFunctionResources( Lists.transform(userDefinedFunctions, UserDefinedFunction.TO_PB_FUNCTION)); } if (writeDisposition != null) { queryConfigurationPb.setWriteDisposition(writeDisposition.toString()); } return configurationPb.setQuery(queryConfigurationPb); }
From source file:com.facebook.buck.parser.PythonDslProjectBuildFileParser.java
@SuppressWarnings("unchecked") private BuildFileManifest toBuildFileManifest(ImmutableList<Map<String, Object>> values) { return BuildFileManifest.of(indexTargetsByName(values.subList(0, values.size() - 3).asList()), ImmutableSortedSet.copyOf(Objects .requireNonNull((List<String>) values.get(values.size() - 3).get(MetaRules.INCLUDES))), Objects.requireNonNull((Map<String, Object>) values.get(values.size() - 2).get(MetaRules.CONFIGS)), Optional.of(ImmutableMap.copyOf(Maps.transformValues( Objects.requireNonNull( (Map<String, String>) values.get(values.size() - 1).get(MetaRules.ENV)), Optional::ofNullable))), ImmutableList.of());/*from w w w. j ava 2 s .c o m*/ }
From source file:io.druid.segment.realtime.appenderator.BaseAppenderatorDriver.java
WrappedCommitter wrapCommitter(final Committer committer) { final AppenderatorDriverMetadata wrappedMetadata; final Map<String, SegmentsForSequence> snapshot; synchronized (segments) { snapshot = ImmutableMap.copyOf(segments); }/*from w ww. j a v a2 s . com*/ wrappedMetadata = new AppenderatorDriverMetadata( ImmutableMap.copyOf(Maps.transformValues(snapshot, (Function<SegmentsForSequence, List<SegmentWithState>>) input -> ImmutableList .copyOf(input.intervalToSegmentStates.values().stream().flatMap(Collection::stream) .collect(Collectors.toList())))), snapshot.entrySet().stream().collect( Collectors.toMap(Entry::getKey, e -> e.getValue().lastSegmentId)), committer.getMetadata()); return new WrappedCommitter(committer, wrappedMetadata); }
From source file:com.facebook.buck.parser.PythonDslProjectBuildFileParser.java
/** * When the given object if a map and it contains specific keys it's transformed in either a * {@link com.facebook.buck.parser.syntax.ListWithSelects} or {@link * com.facebook.buck.parser.syntax.SelectorValue}. This conversion is used to pass objects in JSON * data./* w ww.ja v a 2 s .c o m*/ * * <p>The map may contain the following keys: * * <ul> * <li>{@code @type} - indicates the type of the object (either "SelectorList" or * "SelectorValue"). * <li>{@code conditions} - contains a map of conditions for "SelectorList". * <li>{@code no_match_message} - contains a no match message for "SelectorList". * <li>{@code items} - contains a list of items for "SelectorValue". * </ul> */ @SuppressWarnings("unchecked") private static Object convertToSelectableAttributeIfNeeded(Object value) { if (!(value instanceof Map)) { return value; } Map<String, Object> attributeValue = (Map<String, Object>) value; String type = (String) attributeValue.get("@type"); if (type == null) { return attributeValue; } if ("SelectorValue".equals(type)) { Map<String, Object> conditions = (Map<String, Object>) Objects .requireNonNull(attributeValue.get("conditions")); Map<String, Object> convertedConditions = Maps.transformValues(conditions, v -> v == null ? Runtime.NONE : v); return ImmutableSelectorValue.of(convertedConditions, Objects.toString(attributeValue.get("no_match_message"), "")); } else { Preconditions.checkState("SelectorList".equals(type)); List<Object> items = (List<Object>) Objects.requireNonNull(attributeValue.get("items")); ImmutableList<Object> convertedElements = convertToSelectableAttributesIfNeeded(items); return ImmutableListWithSelects.of(convertedElements, getType(Iterables.getLast(convertedElements))); } }
From source file:org.onosproject.store.ecmap.EventuallyConsistentMapImpl.java
private AntiEntropyAdvertisement<K> createAdvertisement() { return new AntiEntropyAdvertisement<K>(localNodeId, ImmutableMap.copyOf(Maps.transformValues(items, MapValue::digest))); }
From source file:io.druid.segment.realtime.appenderator.FiniteAppenderatorDriver.java
private Committer wrapCommitter(final Committer committer) { synchronized (activeSegments) { final FiniteAppenderatorDriverMetadata wrappedMetadata = new FiniteAppenderatorDriverMetadata( ImmutableMap.copyOf(Maps.transformValues(activeSegments, new Function<NavigableMap<Long, SegmentIdentifier>, List<SegmentIdentifier>>() { @Override public List<SegmentIdentifier> apply(NavigableMap<Long, SegmentIdentifier> input) { return ImmutableList.copyOf(input.values()); }/*from w w w. j a v a2 s . c o m*/ })), ImmutableMap.copyOf(lastSegmentIds), committer.getMetadata()); return new Committer() { @Override public Object getMetadata() { return wrappedMetadata; } @Override public void run() { committer.run(); } }; } }
From source file:cpw.mods.fml.common.Loader.java
private void disableRequestedMods() { String forcedModList = System.getProperty("fml.modStates", ""); FMLLog.finer("Received a system property request \'%s\'", forcedModList); Map<String, String> sysPropertyStateList = Splitter.on(CharMatcher.anyOf(";:")).omitEmptyStrings() .trimResults().withKeyValueSeparator("=").split(forcedModList); FMLLog.finer("System property request managing the state of %d mods", sysPropertyStateList.size()); Map<String, String> modStates = Maps.newHashMap(); forcedModFile = new File(canonicalConfigDir, "fmlModState.properties"); Properties forcedModListProperties = new Properties(); if (forcedModFile.exists() && forcedModFile.isFile()) { FMLLog.finer("Found a mod state file %s", forcedModFile.getName()); try {// w w w . j av a 2 s . c o m forcedModListProperties.load(new FileReader(forcedModFile)); FMLLog.finer("Loaded states for %d mods from file", forcedModListProperties.size()); } catch (Exception e) { FMLLog.log(Level.INFO, e, "An error occurred reading the fmlModState.properties file"); } } modStates.putAll(Maps.fromProperties(forcedModListProperties)); modStates.putAll(sysPropertyStateList); FMLLog.fine("After merging, found state information for %d mods", modStates.size()); Map<String, Boolean> isEnabled = Maps.transformValues(modStates, new Function<String, Boolean>() { @Override public Boolean apply(String input) { return Boolean.parseBoolean(input); } }); for (Map.Entry<String, Boolean> entry : isEnabled.entrySet()) { if (namedMods.containsKey(entry.getKey())) { FMLLog.info("Setting mod %s to enabled state %b", entry.getKey(), entry.getValue()); namedMods.get(entry.getKey()).setEnabledState(entry.getValue()); } } }
From source file:org.janusgraph.diskstorage.Backend.java
/** * Returns the {@link IndexFeatures} of all configured index backends *//*from w ww . j a va2 s .com*/ public Map<String, IndexFeatures> getIndexFeatures() { return Maps.transformValues(indexes, new Function<IndexProvider, IndexFeatures>() { @Nullable @Override public IndexFeatures apply(@Nullable IndexProvider indexProvider) { return indexProvider.getFeatures(); } }); }