Search in sources :

Example 1 with CollectionFeature

use of com.google.common.collect.testing.features.CollectionFeature in project guava by google.

the class MapTestSuiteBuilder method computeCommonDerivedCollectionFeatures.

public static Set<Feature<?>> computeCommonDerivedCollectionFeatures(Set<Feature<?>> mapFeatures) {
    mapFeatures = new HashSet<Feature<?>>(mapFeatures);
    Set<Feature<?>> derivedFeatures = new HashSet<Feature<?>>();
    mapFeatures.remove(CollectionFeature.SERIALIZABLE);
    if (mapFeatures.remove(CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS)) {
        derivedFeatures.add(CollectionFeature.SERIALIZABLE);
    }
    if (mapFeatures.contains(MapFeature.SUPPORTS_REMOVE)) {
        derivedFeatures.add(CollectionFeature.SUPPORTS_REMOVE);
    }
    if (mapFeatures.contains(MapFeature.REJECTS_DUPLICATES_AT_CREATION)) {
        derivedFeatures.add(CollectionFeature.REJECTS_DUPLICATES_AT_CREATION);
    }
    if (mapFeatures.contains(MapFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION)) {
        derivedFeatures.add(CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION);
    }
    // add the intersection of CollectionFeature.values() and mapFeatures
    for (CollectionFeature feature : CollectionFeature.values()) {
        if (mapFeatures.contains(feature)) {
            derivedFeatures.add(feature);
        }
    }
    // add the intersection of CollectionSize.values() and mapFeatures
    for (CollectionSize size : CollectionSize.values()) {
        if (mapFeatures.contains(size)) {
            derivedFeatures.add(size);
        }
    }
    return derivedFeatures;
}
Also used : CollectionSize(com.google.common.collect.testing.features.CollectionSize) CollectionFeature(com.google.common.collect.testing.features.CollectionFeature) CollectionFeature(com.google.common.collect.testing.features.CollectionFeature) Feature(com.google.common.collect.testing.features.Feature) MapFeature(com.google.common.collect.testing.features.MapFeature) HashSet(java.util.HashSet)

Aggregations

CollectionFeature (com.google.common.collect.testing.features.CollectionFeature)1 CollectionSize (com.google.common.collect.testing.features.CollectionSize)1 Feature (com.google.common.collect.testing.features.Feature)1 MapFeature (com.google.common.collect.testing.features.MapFeature)1 HashSet (java.util.HashSet)1