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

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator.java

private SubstatementValidator(final Builder builder) {
    this.cardinalityMap = builder.cardinalityMap.build();
    this.currentStatement = builder.currentStatement;
    this.mandatoryStatements = ImmutableMap.copyOf(Maps.filterValues(cardinalityMap, c -> c.getMin() > 0));
}

From source file:org.atlasapi.application.v3.ApplicationConfiguration.java

private static Set<Publisher> enabledPublishers(Map<Publisher, SourceStatus> sourceStatuses) {
    return ImmutableSet
            .copyOf(Maps.filterValues(allSourcesStatuses(sourceStatuses), SourceStatus.IS_ENABLED).keySet());
}

From source file:org.apache.brooklyn.enricher.stock.MapAggregator.java

@Override
protected Object compute() {
    Map<Entity, Object> ks = MutableMap.copyOf(Maps.filterValues(getValues(keySensor), valueFilter));
    Map<Entity, Object> vs = MutableMap.copyOf(Maps.filterValues(getValues(valueSensor), valueFilter));
    MutableMap<Object, Object> result = MutableMap.of();
    for (Entity entity : ks.keySet()) {
        if (vs.containsKey(entity)) {
            result.put(ks.get(entity), vs.get(entity));
        }//from ww w.j  av  a  2  s .c  o m
    }
    return result;
}

From source file:graph.features.degree.Degree.java

@Override
public Map<T, Integer> getNodesWithOddDegree() {
    return Maps.filterValues(this.getData(), Integers.Predicates.isOdd());
}

From source file:com.torodb.core.transaction.metainf.WrapperMutableMetaDatabase.java

public WrapperMutableMetaDatabase(ImmutableMetaDatabase wrapped,
        Consumer<WrapperMutableMetaDatabase> changeConsumer) {
    this.wrapped = wrapped;
    this.changeConsumer = changeConsumer;

    this.collectionsByName = new HashMap<>();

    wrapped.streamMetaCollections().forEach((collection) -> {
        WrapperMutableMetaCollection mutable = createMetaColletion(collection);

        collectionsByName.put(collection.getName(), new Tuple2<>(mutable, MetaElementState.NOT_CHANGED));
    });//from  w w w .  jav a2 s . c  o m
    aliveCollectionsMap = Maps.filterValues(collectionsByName, tuple -> tuple.v2().isAlive());
}

From source file:graph.features.degree.Degree.java

@Override
public Map<T, Integer> getNodesWithEvenDegree() {
    return Maps.filterValues(this.getData(), Integers.Predicates.isEven());
}

From source file:net.derquinse.common.orm.Entities.java

/** Clears the target map and inserts every non-null element from the source one. */
public static <K, V> void pushMap(Map<K, V> target, Map<? extends K, ? extends V> source) {
    checkNotNull(target);//  w w  w . j a  v a 2s  . c o m
    target.clear();
    if (source != null) {
        target.putAll(Maps.filterKeys(Maps.filterValues(source, Predicates.notNull()), Predicates.notNull()));
    }
}

From source file:eu.lp0.cursus.scoring.scores.impl.GenericRaceDiscardsData.java

@Override
protected List<Race> calculateDiscardedRaces(Pilot pilot) {
    if (discards > 0) {
        final Map<Race, Integer> racePoints = scores.getRacePoints(pilot);

        // Discard the highest scoring races
        return Lists.newArrayList(Iterables.limit(Ordering.from(new Comparator<Race>() {
            @Override// w  ww. j  a  va2 s . co  m
            public int compare(Race o1, Race o2) {
                return ComparisonChain.start().compare(racePoints.get(o2), racePoints.get(o1)).compare(o1, o2)
                        .result();
            }
            // Use all races where the score is not null
        }).immutableSortedCopy(Maps.filterValues(racePoints, Predicates.notNull()).keySet()), discards));
    }

    return Collections.emptyList();
}

From source file:io.joynr.caching.ClientHashMapCache.java

public void cleanUp() {
    Map<String, CachedValue> result = Maps.filterValues(cache, new QoSCacheEntryTimeToLiveCompatibility(qos));
    for (String attributeId : result.keySet()) {
        cache.remove(attributeId);// w w  w. j  a va2  s .c  om
    }
}

From source file:org.jclouds.cloudstack.predicates.OSCategoryIn.java

@Override
public Predicate<Template> apply(final Set<String> acceptableCategories) {
    final Map<String, String> categories = categoriesSupplier.get();
    final Set<String> acceptableOSTypeIds = Maps.filterValues(
            Maps.transformValues(Maps.uniqueIndex(osTypesSupplier.get(), new Function<OSType, String>() {

                @Override/* w  w  w  .j  ava  2 s. c  o  m*/
                public String apply(OSType input) {
                    return input.getId();
                }

            }), new Function<OSType, String>() {

                @Override
                public String apply(OSType input) {
                    return categories.get(input.getOSCategoryId());
                }

            }), Predicates.in(acceptableCategories)).keySet();
    return new Predicate<Template>() {

        @Override
        public boolean apply(Template input) {
            return Predicates.in(acceptableOSTypeIds).apply(input.getOSTypeId());
        }

        @Override
        public String toString() {
            return "OSCategoryIn(" + acceptableCategories + ")";
        }
    };
}