Example usage for com.google.common.collect Maps transformValues

List of usage examples for com.google.common.collect Maps transformValues

Introduction

In this page you can find the example usage for com.google.common.collect Maps transformValues.

Prototype

@GwtIncompatible("NavigableMap")
public static <K, V1, V2> NavigableMap<K, V2> transformValues(NavigableMap<K, V1> fromMap,
        Function<? super V1, V2> function) 

Source Link

Document

Returns a view of a navigable map where each value is transformed by a function.

Usage

From source file:org.imsglobal.caliper.Sensor.java

/**
 * Returns//ww  w  .  ja v a 2  s . c om
 * @return a map where the keys are the identifying objects and the values are the corresponding statistics
 * for that key's Client.
 */
public Map<T, Statistics> getStatistics() {
    return Maps.transformValues(clients, new Function<Client, Statistics>() {
        @Nullable
        @Override
        public Statistics apply(@Nullable Client client) {
            return client.getStatistics();
        }
    });
}

From source file:org.onosproject.provider.lldp.impl.SuppressionConfig.java

/**
 * Sets annotation of Ports on which LinkDiscovery is suppressed.
 *
 * @param annotation new key-value pair of annotation; null to clear
 * @return self/*from www.j a v a 2  s .co  m*/
 */
public SuppressionConfig annotation(Map<String, String> annotation) {

    // ANY_VALUE should be null in JSON
    Map<String, String> config = Maps.transformValues(annotation,
            v -> (v == SuppressionRules.ANY_VALUE) ? null : v);

    String jsonAnnotation = null;

    try {
        // TODO Store annotation as a Map instead of a String (which needs NetworkConfigRegistry modification)
        jsonAnnotation = MAPPER.writeValueAsString(config);
    } catch (JsonProcessingException e) {
        log.error("Failed to write JSON from: {}", annotation);
    }

    return (SuppressionConfig) setOrClear(ANNOTATION, jsonAnnotation);
}

From source file:org.richfaces.request.MultipartRequest25.java

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override/*from ww  w. j  av a 2s .  com*/
public Map getParameterMap() {
    Map parameterMap = Maps.newHashMap(super.getParameterMap());
    parseIfNecessary();
    parameterMap.putAll(Maps.transformValues(params.asMap(), MULTIMAP_VALUE_TRANSFORMER));

    return parameterMap;
}

From source file:de.metas.ui.web.window.model.IncludedDocumentsCollection.java

/** copy constructor */
private IncludedDocumentsCollection(@NonNull final IncludedDocumentsCollection from,
        @NonNull final Document parentDocumentCopy, @NonNull final CopyMode copyMode) {
    parentDocument = parentDocumentCopy;
    entityDescriptor = from.entityDescriptor;

    // State/*from  www.  j a  v  a2  s  .  c o  m*/
    _fullyLoaded = from._fullyLoaded;
    _staleDocumentIds = new HashSet<>(from._staleDocumentIds);
    actions = from.actions.copy();

    // Deep-copy documents map
    _documents = new LinkedHashMap<>(Maps.transformValues(from._documents,
            includedDocumentOrig -> includedDocumentOrig.copy(parentDocumentCopy, copyMode)));
}

From source file:ninja.leaping.permissionsex.sponge.PEXSubjectData.java

@Override
public Map<String, Boolean> getPermissions(Set<Context> set) {
    return Maps.transformValues(data.get().getPermissions(parSet(set)), value -> value > 0);
}

From source file:org.apache.brooklyn.util.core.config.ResolvingConfigBag.java

@Override
public Map<ConfigKey<?>, ?> getAllConfigAsConfigKeyMap() {
    // Lazily transform copy of map
    return Maps.transformValues(super.getAllConfigAsConfigKeyMap(), getTransformer());
}

From source file:org.eclipse.sw360.licenseinfo.outputGenerators.OutputGenerator.java

@NotNull
protected SortedMap<String, Set<String>> getSortedAcknowledgements(
        Map<String, LicenseInfoParsingResult> sortedLicenseInfos) {
    Map<String, Set<String>> acknowledgements = Maps.filterValues(
            Maps.transformValues(sortedLicenseInfos, pr -> Optional.ofNullable(pr.getLicenseInfo())
                    .map(LicenseInfo::getLicenseNamesWithTexts).filter(Objects::nonNull)
                    .map(s -> s.stream().map(LicenseNameWithText::getAcknowledgements).filter(Objects::nonNull)
                            .collect(Collectors.toSet()))
                    .orElse(Collections.emptySet())),
            set -> !set.isEmpty());//from w  w w  .  j ava2 s. c  om
    return sortStringKeyedMap(acknowledgements);
}

From source file:io.urmia.job.pub.InputAwareZkJobQueue.java

private Map<String, JobInput> split(JobInput input) throws Exception {
    ImmutableMultimap.Builder<String, ObjectName> b = ImmutableMultimap.builder();

    for (/*ObjectName*/String in : input) {
        Optional<ObjectName> optOn = ObjectName.of(in);
        if (!optOn.isPresent()) {
            log.warn("no ObjectName for input: {}", in);
            continue;
        }/* w  w  w  .  j a  va  2 s .co m*/
        ObjectName on = optOn.get();
        ServiceInstance<NodeType> s = whereIs(on);
        log.info("looking where is on: {} -> {}", on, s);
        if (s != null)
            b.put(s.getId(), on);
    }

    Map<String, Collection<ObjectName>> m = b.build().asMap();

    return Maps.transformValues(m, transformer());
}

From source file:com.palantir.atlasdb.keyvalue.impl.AbstractKeyValueService.java

@Override
public Map<Cell, Long> getLatestTimestamps(String tableName, Map<Cell, Long> keys) {
    return Maps.newHashMap(Maps.transformValues(get(tableName, keys), Value.GET_TIMESTAMP));
}

From source file:com.cloudera.csd.StringInterpolator.java

/**
 * Iterates through all the values of the map and substitutes
 * variables as given by the provider. If the templates
 * map is null, an empty map is returned.
 *
 * @param templates the templates map./*from   ww  w .j a  v a2s  .  c om*/
 * @param provider the variable provider.
 * @return a new map with converted values.
 */
public Map<String, String> interpolateValues(@Nullable Map<String, String> templates,
        VariableProvider provider) {
    if (templates == null) {
        return ImmutableMap.of();
    }
    Function<String, String> transformer = transformer(provider);
    return Maps.transformValues(templates, transformer);
}