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;
}
Aggregations