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.facebook.buck.apple.AppleLibraryBuilder.java

public AppleLibraryBuilder setLangPreprocessorFlags(
        ImmutableMap<AbstractCxxSource.Type, ImmutableList<String>> langPreprocessorFlags) {
    getArgForPopulating().setLangPreprocessorFlags(Maps.transformValues(langPreprocessorFlags,
            f -> RichStream.from(f).map(StringWithMacrosUtils::format).toImmutableList()));
    return this;
}

From source file:info.archinnov.achilles.context.CQLDaoContextBuilder.java

public CQLDaoContext build(Map<Class<?>, EntityMeta> entityMetaMap, boolean hasSimpleCounter) {
    Map<Class<?>, PreparedStatement> insertPSMap = new HashMap<Class<?>, PreparedStatement>(
            Maps.transformValues(Maps.filterValues(entityMetaMap, excludeClusteredCounterFilter),
                    insertPSTransformer));

    Map<Class<?>, PreparedStatement> selectEagerPSMap = new HashMap<Class<?>, PreparedStatement>(
            Maps.transformValues(entityMetaMap, selectEagerPSTransformer));

    Map<Class<?>, Map<String, PreparedStatement>> removePSMap = new HashMap<Class<?>, Map<String, PreparedStatement>>(
            Maps.transformValues(entityMetaMap, removePSTransformer));

    Cache<StatementCacheKey, PreparedStatement> dynamicPSCache = CacheBuilder.newBuilder()
            .maximumSize(PREPARED_STATEMENT_LRU_CACHE_SIZE).build();

    Map<CQLQueryType, PreparedStatement> counterQueryMap;
    if (hasSimpleCounter) {
        counterQueryMap = queryGenerator.prepareSimpleCounterQueryMap(session);
    } else {//from   w ww  . j  a  va 2 s. c o  m
        counterQueryMap = new HashMap<CQLQueryType, PreparedStatement>();
    }

    Map<Class<?>, Map<CQLQueryType, PreparedStatement>> clusteredCounterQueriesMap = new HashMap<Class<?>, Map<CQLQueryType, PreparedStatement>>(
            Maps.transformValues(Maps.filterValues(entityMetaMap, clusteredCounterFilter),
                    clusteredCounterTransformer));

    return new CQLDaoContext(insertPSMap, dynamicPSCache, selectEagerPSMap, removePSMap, counterQueryMap,
            clusteredCounterQueriesMap, session);
}

From source file:com.google.jenkins.plugins.metadata.MetadataContainer.java

/**
 * @return the serialized form of the metadata;
 *//* w  w w  .  j  a v a  2 s.com*/
public Map<String, String> getSerializedMetadata() {
    return Maps.newHashMap(
            Maps.transformValues(metadata.asMap(), new Function<Collection<MetadataValue>, String>() {
                @Override
                public String apply(Collection<MetadataValue> values) {
                    return listSerialize(values);
                }
            }));
}

From source file:org.apache.beam.runners.spark.aggregators.NamedAggregators.java

/**
 * @return a map of all the aggregator names and their <b>rendered </b>values
 *//*from   ww  w . j a  va2 s . com*/
public Map<String, ?> renderAll() {
    return ImmutableMap.copyOf(Maps.transformValues(mNamedAggregators, new Function<State<?, ?, ?>, Object>() {

        @Override
        public Object apply(State<?, ?, ?> state) {
            return state.render();
        }
    }));
}

From source file:com.facebook.swift.codec.ArrayField.java

public Map<Short, List<Boolean>> getMapBooleanList() {
    if (mapBooleanArray == null) {
        return null;
    }// w  w w. j a v a 2  s.  c om
    return Maps.transformValues(mapBooleanArray, booleanArrayAsList());
}

From source file:io.airlift.drift.codec.ArrayField.java

public Map<Short, List<Boolean>> getMapBooleanList() {
    if (mapBooleanArray == null) {
        return null;
    }/*w  w  w .  java  2 s.  c o  m*/
    return Maps.transformValues(mapBooleanArray, Booleans::asList);
}

From source file:io.atomix.core.election.impl.TranscodingAsyncLeaderElector.java

@Override
public CompletableFuture<Map<String, Leadership<V1>>> getLeaderships() {
    return backingElector.getLeaderships().thenApply(
            leaderships -> Maps.transformValues(leaderships, leadership -> leadership.map(valueDecoder)));
}

From source file:org.eclipse.che.vfs.impl.fs.WorkspaceToDirectoryMappingService.java

@GET
@Consumes(MediaType.APPLICATION_JSON)//  ww w .ja  v a 2 s .  co m
@Produces(MediaType.APPLICATION_JSON)
public Map<String, String> getDirectoryMapping() throws ServerException {
    Map<String, String> directoryMapping;
    if (mappedDirectoryLocalFSMountStrategy.getDirectoryMapping().isEmpty()) {
        directoryMapping = new HashMap<>();
        directoryMapping.put("__default", rootDir);
        return directoryMapping;
    }
    directoryMapping = Maps.transformValues(mappedDirectoryLocalFSMountStrategy.getDirectoryMapping(),
            new Function<File, String>() {
                @Override
                public String apply(File input) {
                    return input.getAbsolutePath();
                }
            });

    return directoryMapping;
}

From source file:org.jclouds.internal.FilterStringsBoundToInjectorByName.java

@Override
public Map<String, String> apply(Predicate<String> filter) {
    List<Binding<String>> stringBindings = injector.findBindingsByType(TypeLiteral.get(String.class));
    Iterable<Binding<String>> annotatedWithName = Iterables.filter(stringBindings,
            new Predicate<Binding<String>>() {

                @Override//  w w  w  .  j  a v a  2s  .  c  o m
                public boolean apply(Binding<String> input) {
                    Annotation annotation = input.getKey().getAnnotation();
                    if (annotation == null)
                        return false;
                    return (annotation instanceof javax.inject.Named)
                            || (annotation instanceof com.google.inject.name.Named);
                }

            });

    Map<String, Binding<String>> bindingsByName = Maps.uniqueIndex(annotatedWithName,
            new Function<Binding<String>, String>() {

                @Override
                public String apply(Binding<String> input) {
                    Annotation annotation = input.getKey().getAnnotation();
                    return (annotation instanceof javax.inject.Named)
                            ? javax.inject.Named.class.cast(annotation).value()
                            : com.google.inject.name.Named.class.cast(annotation).value();
                }

            });

    Map<String, Binding<String>> filteredBindingsByName = Maps.filterKeys(bindingsByName, filter);

    Map<String, String> stringBoundByName = Maps.transformValues(filteredBindingsByName,
            new Function<Binding<String>, String>() {

                @Override
                public String apply(Binding<String> input) {
                    return input.getProvider().get();
                }
            });
    return stringBoundByName;
}

From source file:com.google.devtools.build.skyframe.InMemoryGraph.java

/**
 * Returns a read-only live view of the nodes in the graph. All node are included. Dirty values
 * include their Node value. Values in error have a null value.
 *///from  w ww  .j  a  v a 2s.c  o m
Map<SkyKey, SkyValue> getValues() {
    return Collections.unmodifiableMap(Maps.transformValues(nodeMap, new Function<NodeEntry, SkyValue>() {
        @Override
        public SkyValue apply(NodeEntry entry) {
            return entry.toValue();
        }
    }));
}