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:com.exoplatform.iversion.Version.java

public Map<K, VersionProperty<V>> getVersionProperties() {
    return Maps.transformValues(properties, toVersionProperties());
}

From source file:com.codepine.api.testrail.internal.StringToMapDeserializer.java

@Override
public Map<String, String> deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    if (jp.getValueAsString() == null) {
        return null;
    }/* w  ww.ja v a 2  s  .  c om*/
    Map<String, String> items = Splitter.on("\n").omitEmptyStrings().withKeyValueSeparator(',')
            .split(jp.getValueAsString());
    items = Maps.transformValues(items, new Function<String, String>() {
        @Override
        public String apply(String value) {
            return value.trim();
        }
    });
    return items;
}

From source file:com.proofpoint.event.monitor.MonitorEventTapResource.java

@GET
@Path("/stats")
@Produces(MediaType.APPLICATION_JSON)//w  ww  . j  a  v a2s.co m
public Map<String, Integer> getStats() {
    return Maps.transformValues(history, new Function<AtomicInteger, Integer>() {
        @Override
        public Integer apply(@Nullable AtomicInteger atomicInteger) {
            return atomicInteger.get();
        }
    });
}

From source file:com.palantir.atlasdb.keyvalue.partition.quorum.QuorumTracker.java

public QuorumTracker(Iterable<TrackingUnit> allTrackedUnits,
        Map<TrackingUnit, QuorumRequestParameters> quorumRequestParameters) {
    numberOfRemainingFailuresForFailure = Maps.newHashMap(
            Maps.transformValues(quorumRequestParameters, new Function<QuorumRequestParameters, Integer>() {
                @Override//from  ww w.j a  v a2 s  . c  om
                public Integer apply(QuorumRequestParameters input) {
                    return input.getFailureFactor();
                }
            }));
    numberOfRemainingSuccessesForSuccess = Maps.newHashMap(
            Maps.transformValues(quorumRequestParameters, new Function<QuorumRequestParameters, Integer>() {
                @Override
                public Integer apply(QuorumRequestParameters input) {
                    return input.getSuccessFactor();
                }
            }));
    Preconditions.checkArgument(
            numberOfRemainingFailuresForFailure.keySet().equals(Sets.newHashSet(allTrackedUnits)));
    Preconditions.checkArgument(
            numberOfRemainingSuccessesForSuccess.keySet().equals(Sets.newHashSet(allTrackedUnits)));
    unitsByReference = Maps.newHashMap();
    failure = false;
}

From source file:ninja.leaping.permissionsex.bukkit.PEXPermissionAttachment.java

@Override
public Map<String, Boolean> getPermissions() {
    return Maps.transformValues(subjectData.get().getPermissions(PermissionsEx.GLOBAL_CONTEXT), val -> val > 0);
}

From source file:org.ow2.sirocco.cloudmanager.api.openstack.server.resources.nova.functions.queries.AbstractQuery.java

@Override
public QueryParams apply(org.ow2.sirocco.cloudmanager.api.openstack.commons.resource.JaxRsRequestInfo input) {
    if (RequestHelper.getQueryParameters(input).size() == 0) {
        return null;
    }/*from   w w w  .j a  va 2  s.co m*/

    // let's get all parameters and map to the sirocco model...
    Map<String, List<String>> params = RequestHelper.getQueryParameters(input);
    final Map<String, String> p = Maps.transformValues(params, new Function<List<String>, String>() {
        @Override
        public String apply(List<String> input) {
            return input.get(0);
        }
    });

    List<Query> filter = Lists.newArrayList(
            Iterators.filter(Iterators.transform(p.keySet().iterator(), new Function<String, Query>() {
                @Override
                public Query apply(String key) {
                    Query q = getQuery(key.toLowerCase());
                    q.name = getSiroccoParamName(key.toLowerCase());
                    q.operator = "=";
                    q.value = getSiroccoParamValue(key, p.get(key));
                    return q;
                }
            }), new Predicate<Query>() {
                // do not keep query with null names. It means that there is no mapping between openstack and sirocco...
                @Override
                public boolean apply(ServerListQuery.Query input) {
                    return input.name != null;
                }
            }));

    List<String> f = Lists.transform(filter, new Function<Query, String>() {
        @Override
        public String apply(ServerListQuery.Query input) {
            return input.toString();
        }
    });
    LOG.info("Query list : " + f);

    return new QueryParams.Builder().filters(f).build();
}

From source file:io.fabric8.docker.provider.customizer.ApplyConfigurationStep.java

public void install() 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));

    applyTemplates(renderedTemplates, baseDir);
    applyPlainConfiguration(plainFiles, baseDir);
}

From source file:org.richfaces.integration.skin.AbstractSkinTestBase.java

protected Map<String, String> parseQueryParameters(URL url) {
    return Maps.transformValues(HttpUtils.parseQueryString(url.getQuery()), new Function<String[], String>() {
        @Override//w w w  .java2  s .  c o  m
        public String apply(String[] input) {
            return input[0];
        }
    });
}

From source file:io.fabric8.process.manager.support.ApplyConfigurationTask.java

@Override
public void install(InstallContext installContext, 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();
    ProcessManagerService.substituteEnvironmentVariableExpressions((Map) variables, config.getEnvironment());
    Map<String, String> renderedTemplates = Maps.transformValues(templates,
            new MvelTemplateRendering(variables));
    File baseDir = ProcessUtils.findInstallDir(installDir);
    applyTemplates(installContext, renderedTemplates, baseDir);
    applyPlainConfiguration(installContext, plainFiles, baseDir);

}

From source file:com.palantir.atlasdb.transaction.impl.ConflictDetectionManagers.java

private static Map<String, ConflictHandler> getTablesToConflictDetect(KeyValueService kvs) {
    return ImmutableMap
            .copyOf(Maps.transformValues(kvs.getMetadataForTables(), new Function<byte[], ConflictHandler>() {
                @Override//from  w  w w .ja v  a 2s. com
                public ConflictHandler apply(byte[] metadataForTable) {
                    if (metadataForTable != null && metadataForTable.length > 0) {
                        return TableMetadata.BYTES_HYDRATOR.hydrateFromBytes(metadataForTable)
                                .getConflictHandler();
                    } else {
                        return ConflictHandler.RETRY_ON_WRITE_WRITE;
                    }
                }
            }));
}