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

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

Introduction

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

Prototype

@CheckReturnValue
public static <K, V> BiMap<K, V> filterKeys(BiMap<K, V> unfiltered, final Predicate<? super K> keyPredicate) 

Source Link

Document

Returns a bimap containing the mappings in unfiltered whose keys satisfy a predicate.

Usage

From source file:com.proofpoint.tracetoken.TraceToken.java

@JsonCreator
static TraceToken createJson(Map<String, String> map) {
    return new TraceToken(Maps.filterKeys(map, key -> !key.startsWith("_")));
}

From source file:com.enonic.cms.core.config.ConfigProperties.java

public Map<String, String> getSubMap(final Predicate<String> predicate) {
    return Maps.filterKeys(getMap(), predicate);
}

From source file:dagger.internal.codegen.BindingGraphPluginsModule.java

@Provides
@Singleton//  w  ww .j  a  v  a 2 s  . com
static ImmutableList<BindingGraphPlugin> bindingGraphPlugins(Filer filer,
        @ProcessingOptions Map<String, String> processingOptions) {
    ClassLoader classLoader = BindingGraphPluginsModule.class.getClassLoader();
    ImmutableList<BindingGraphPlugin> bindingGraphPlugins = ImmutableList
            .copyOf(ServiceLoader.load(BindingGraphPlugin.class, classLoader));
    for (BindingGraphPlugin plugin : bindingGraphPlugins) {
        plugin.setFiler(filer);
        Set<String> supportedOptions = plugin.getSupportedOptions();
        if (!supportedOptions.isEmpty()) {
            plugin.setOptions(Maps.filterKeys(processingOptions, supportedOptions::contains));
        }
    }
    return bindingGraphPlugins;
}

From source file:org.trancecode.collection.TcMaps.java

public static <K, V> Map<K, V> merge(final Map<K, V> map1, final Map<? extends K, ? extends V> map2) {
    final Builder<K, V> builder = ImmutableMap.builder();
    @SuppressWarnings("unchecked")
    final Set<K> map2keys = (Set<K>) map2.keySet();
    final Predicate<K> keyFilter = Predicates.not(TcPredicates.isContainedBy(map2keys));
    final Map<K, V> map1WithoutKeysFromMap2 = Maps.filterKeys(map1, keyFilter);
    return builder.putAll(map1WithoutKeysFromMap2).putAll(map2).build();
}

From source file:org.jfrog.build.extractor.clientConfiguration.util.DeploymentUrlUtils.java

/**
 * Calculate the full Artifactory deployment URL which includes the matrix params appended to it. see {@link
 * org.jfrog.build.extractor.clientConfiguration.ClientProperties#PROP_DEPLOY_PARAM_PROP_PREFIX} for the property prefix that this method takes into account.
 *
 * @param artifactoryUrl The Artifactory upload URL.
 * @param properties     The properties to append to the Artifactory URL.
 * @return The generated Artifactory URL with the matrix params appended to it.
 */// w  w  w .  jav  a 2s  .  co  m
public static String getDeploymentUrl(String artifactoryUrl, Properties properties)
        throws UnsupportedEncodingException {
    Map<Object, Object> filteredProperties = Maps.filterKeys(properties, new Predicate<Object>() {
        public boolean apply(Object input) {
            String inputKey = (String) input;
            return inputKey.startsWith(ClientProperties.PROP_DEPLOY_PARAM_PROP_PREFIX);
        }
    });
    StringBuilder deploymentUrl = new StringBuilder(artifactoryUrl);
    Set<Map.Entry<Object, Object>> propertyEntries = filteredProperties.entrySet();
    for (Map.Entry<Object, Object> propertyEntry : propertyEntries) {
        String key = StringUtils.removeStart((String) propertyEntry.getKey(),
                ClientProperties.PROP_DEPLOY_PARAM_PROP_PREFIX);
        deploymentUrl.append(";").append(URLEncoder.encode(key, "UTF-8")).append("=")
                .append(URLEncoder.encode(((String) propertyEntry.getValue()), "UTF-8"));
    }
    return deploymentUrl.toString();
}

From source file:com.eviware.loadui.impl.layout.LayoutComponentImpl.java

public LayoutComponentImpl(Map<String, ?> args) {
    properties = ImmutableMap.copyOf(Maps.filterKeys(args, Predicates.notNull()));
}

From source file:io.prestosql.server.NodeResource.java

@GET
@Path("failed")
public Collection<HeartbeatFailureDetector.Stats> getFailed() {
    return Maps.filterKeys(failureDetector.getStats(), in(failureDetector.getFailed())).values();
}

From source file:io.prestosql.sql.planner.iterative.rule.PruneAggregationColumns.java

@Override
protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator,
        AggregationNode aggregationNode, Set<Symbol> referencedOutputs) {
    Map<Symbol, AggregationNode.Aggregation> prunedAggregations = Maps
            .filterKeys(aggregationNode.getAggregations(), referencedOutputs::contains);

    if (prunedAggregations.size() == aggregationNode.getAggregations().size()) {
        return Optional.empty();
    }/*from   w w  w .j a va  2 s . c  om*/

    // PruneAggregationSourceColumns will subsequently project off any newly unused inputs.
    return Optional.of(new AggregationNode(aggregationNode.getId(), aggregationNode.getSource(),
            prunedAggregations, aggregationNode.getGroupingSets(), aggregationNode.getPreGroupedSymbols(),
            aggregationNode.getStep(), aggregationNode.getHashSymbol(), aggregationNode.getGroupIdSymbol()));
}

From source file:org.trancecode.collection.TcMaps.java

public static <K, V> Map<K, V> copyAndPut(final Map<K, V> map, final K key, final V value) {
    Preconditions.checkNotNull(map);//from  w w w .ja  va 2  s  .c o m
    Preconditions.checkNotNull(key);
    if (map instanceof ImmutableMap && TcObjects.equals(map.get(key), value)) {
        return map;
    }

    final Builder<K, V> builder = ImmutableMap.builder();
    final Map<K, V> mapWithoutKey = Maps.filterKeys(map, Predicates.not(Predicates.equalTo(key)));
    return builder.putAll(mapWithoutKey).put(key, value).build();
}

From source file:com.facebook.presto.sql.planner.iterative.rule.PruneAggregationColumns.java

@Override
protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator,
        AggregationNode aggregationNode, Set<Symbol> referencedOutputs) {
    Map<Symbol, AggregationNode.Aggregation> prunedAggregations = Maps
            .filterKeys(aggregationNode.getAggregations(), referencedOutputs::contains);

    if (prunedAggregations.size() == aggregationNode.getAggregations().size()) {
        return Optional.empty();
    }/* w w  w .jav  a  2  s. c  om*/

    // PruneAggregationSourceColumns will subsequently project off any newly unused inputs.
    return Optional.of(new AggregationNode(aggregationNode.getId(), aggregationNode.getSource(),
            prunedAggregations, aggregationNode.getGroupingSets(), aggregationNode.getStep(),
            aggregationNode.getHashSymbol(), aggregationNode.getGroupIdSymbol()));
}