SortedAttributeMetadata extends AttributeMetadata<A, O> { public Stream<A> getDistinctKeysDescending() { QueryOptions queryOptions = openResources(); return asStream(queryOptions, index.getDistinctKeysDescending(queryOptions)); } SortedAttributeMetadata(SortedKeyStatisticsIndex<A, O> index, Supplier<QueryOptions> openResourcesHandler, Consumer<QueryOptions> closeResourcesHandler); @Override Stream<KeyFrequency<A>> getFrequencyDistribution(); Stream<KeyFrequency<A>> getFrequencyDistributionDescending(); @Override Stream<A> getDistinctKeys(); Stream<A> getDistinctKeysDescending(); Stream<A> getDistinctKeys(A lowerBound, boolean lowerInclusive, A upperBound, boolean upperInclusive); Stream<A> getDistinctKeysDescending(A lowerBound, boolean lowerInclusive, A upperBound, boolean upperInclusive); @Override Integer getCountOfDistinctKeys(); @Override Integer getCountForKey(A key); @Override Stream<KeyValue<A, O>> getKeysAndValues(); Stream<KeyValue<A, O>> getKeysAndValuesDescending(); Stream<KeyValue<A, O>> getKeysAndValues(A lowerBound, boolean lowerInclusive, A upperBound, boolean upperInclusive); Stream<KeyValue<A, O>> getKeysAndValuesDescending(A lowerBound, boolean lowerInclusive, A upperBound, boolean upperInclusive);  }
@Test public void testGetDistinctKeysDescending() { IndexedCollection<Car> cars = createIndexedCollectionOfCars(20); cars.addIndex(NavigableIndex.onAttribute(Car.MODEL)); MetadataEngine<Car> metadataEngine = cars.getMetadataEngine(); SortedAttributeMetadata<String, Car> sortedAttributeMetadata = metadataEngine.getSortedAttributeMetadata(Car.MODEL); assertEquals( asList("Taurus", "Prius", "M6", "Insight", "Hilux", "Fusion", "Focus", "Civic", "Avensis", "Accord"), sortedAttributeMetadata.getDistinctKeysDescending().collect(toList()) ); assertEquals( asList("Hilux", "Fusion", "Focus"), sortedAttributeMetadata.getDistinctKeysDescending("Civic", false, "Insight", false).collect(toList()) ); assertEquals( asList("Prius", "M6", "Insight", "Hilux", "Fusion", "Focus", "Civic", "Avensis"), sortedAttributeMetadata.getDistinctKeysDescending("Alpha", false, "Tango", false).collect(toList()) ); }