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:eu.esdihumboldt.hale.common.instance.model.impl.FilteredInstanceCollection.java

@Override
public Map<TypeDefinition, InstanceCollection> fanout() {
    Map<TypeDefinition, InstanceCollection> fanout = super.fanout();
    if (fanout != null) {
        return Maps.transformValues(fanout, new Function<InstanceCollection, InstanceCollection>() {

            @Override// w  w  w. ja v  a 2s . c o  m
            public InstanceCollection apply(InstanceCollection from) {
                return new FilteredInstanceCollection(from, filter);
            }
        });
    }

    return null;
}

From source file:com.eucalyptus.ws.handlers.HmacHandler.java

private Map<String, List<String>> processParametersForVariant(final MappingHttpRequest httpRequest,
        final HmacUtils.SignatureVariant variant) {
    Map<String, String> result = httpRequest.getParameters();
    if (variant.getVersion().value() > 2) {
        result = Maps.newHashMap();//from  w  w  w  .j  av a 2  s. c  o m
        for (final Map.Entry<String, String> entry : httpRequest.getParameters().entrySet()) {
            if (httpRequest.isQueryParameter(entry.getKey())) {
                result.put(entry.getKey(), entry.getValue());
            }
        }
    }
    return Maps.transformValues(result, CollectionUtils.<String>listUnit());
}

From source file:com.github.rinde.rinsim.experiment.ExperimentCli.java

static Map<String, String> toStringMap(Map<String, MASConfiguration> configMap) {
    return Maps.transformValues(configMap, ConfigToName.INSTANCE);
}

From source file:ninja.leaping.permissionsex.backend.sql.SqlSubjectData.java

@Override
public ImmutableSubjectData clearPermissions() {
    if (this.segments.isEmpty()) {
        return this;
    }/*from ww  w  . j av a2 s . c o m*/

    Map<Set<Entry<String, String>>, Segment> newValue = Maps.transformValues(this.segments,
            dataEntry -> dataEntry == null ? null : dataEntry.withoutPermissions());
    return newWithUpdate(newValue, createBulkUpdateFunc(newValue.keySet()));
}

From source file:ninja.leaping.permissionsex.backend.memory.MemoryOptionSubjectData.java

@Override
public Map<Set<Entry<String, String>>, Map<String, String>> getAllOptions() {
    return Maps.filterValues(Maps.transformValues(contexts, new Function<DataEntry, Map<String, String>>() {
        @Nullable//ww  w .  ja  va  2 s.c o m
        @Override
        public Map<String, String> apply(@Nullable DataEntry dataEntry) {
            return dataEntry == null ? null : dataEntry.options;
        }
    }), Predicates.notNull());
}

From source file:com.continuuity.weave.internal.appmaster.RunningContainers.java

/**
 * Returns a Map contains running instances of all runnables.
 *//*  w ww  .j av  a 2  s. c  o m*/
Map<String, Integer> countAll() {
    containerLock.lock();
    try {
        return ImmutableMap.copyOf(Maps.transformValues(runnableInstances, BITSET_CARDINALITY));
    } finally {
        containerLock.unlock();
    }
}

From source file:org.jclouds.joyent.cloudapi.v6_5.domain.Dataset.java

/**
 * If the value is a string, it will be quoted, as that's how json strings are represented.
 * //from   ww  w  .  java2  s  .c o m
 * @return key to a json literal of the value
 * @see #getRequirements
 * @see Json#fromJson
 */
public Map<String, String> getRequirementsAsJsonLiterals() {
    return Maps.transformValues(requirements, Functions.toStringFunction());
}

From source file:org.apache.bookkeeper.mledger.impl.ManagedLedgerFactoryImpl.java

/**
 * Helper for getting stats//from w  ww  . ja  v  a  2  s.c o  m
 *
 * @return
 */
public Map<String, ManagedLedgerImpl> getManagedLedgers() {
    // Return a view of already created ledger by filtering futures not yet completed
    return Maps.filterValues(Maps.transformValues(ledgers, future -> future.getNow(null)),
            Predicates.notNull());
}

From source file:org.apache.aurora.scheduler.http.SchedulerzRole.java

private Map<IJobKey, Map<?, ?>> fetchCronJobsBy(final String role, final Optional<String> environment) {

    Predicate<IJobConfiguration> byRoleEnv = new Predicate<IJobConfiguration>() {
        @Override//from w  w w .j  av  a2 s .  c o  m
        public boolean apply(IJobConfiguration job) {
            boolean roleMatch = job.getOwner().getRole().equals(role);
            boolean envMatch = !environment.isPresent()
                    || job.getKey().getEnvironment().equals(environment.get());
            return roleMatch && envMatch;
        }
    };

    Iterable<IJobConfiguration> jobs = FluentIterable.from(cronJobManager.getJobs()).filter(byRoleEnv);

    return Maps.transformValues(Maps.uniqueIndex(jobs, JobKeys.FROM_CONFIG),
            new Function<IJobConfiguration, Map<?, ?>>() {
                @Override
                public Map<?, ?> apply(IJobConfiguration job) {
                    return ImmutableMap.<Object, Object>builder().put("jobKey", job.getKey())
                            .put("name", job.getKey().getName())
                            .put("environment", job.getKey().getEnvironment())
                            .put("pendingTaskCount", job.getInstanceCount())
                            .put("cronSchedule", job.getCronSchedule())
                            .put("nextRun", cronPredictor.predictNextRun(job.getCronSchedule()).getTime())
                            .put("cronCollisionPolicy", cronCollisionPolicy(job))
                            .put("packages", getPackages(job)).build();
                }
            });
}

From source file:org.apache.druid.client.DruidServer.java

public ImmutableDruidServer toImmutableDruidServer() {
    return new ImmutableDruidServer(metadata, currSize, ImmutableMap.copyOf(
            Maps.transformValues(dataSources, new Function<DruidDataSource, ImmutableDruidDataSource>() {
                @Override//from   ww w  . j  a v a 2s  .c o  m
                public ImmutableDruidDataSource apply(DruidDataSource input) {
                    return input.toImmutableDruidDataSource();
                }
            })), ImmutableMap.copyOf(segments));
}