SortedAttributeMetadata extends AttributeMetadata<A, O> { @Override public Stream<A> getDistinctKeys() { return super.getDistinctKeys(); } 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 testGetDistinctKeys() { 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("Accord", "Avensis", "Civic", "Focus", "Fusion", "Hilux", "Insight", "M6", "Prius", "Taurus"), sortedAttributeMetadata.getDistinctKeys().collect(toList()) ); assertEquals( asList("Civic", "Focus", "Fusion", "Hilux", "Insight"), sortedAttributeMetadata.getDistinctKeys("Civic", true, "Insight", true).collect(toList()) ); assertEquals( asList("Focus", "Fusion", "Hilux"), sortedAttributeMetadata.getDistinctKeys("Civic", false, "Insight", false).collect(toList()) ); assertEquals( asList("Avensis", "Civic", "Focus", "Fusion", "Hilux", "Insight", "M6", "Prius"), sortedAttributeMetadata.getDistinctKeys("Alpha", false, "Tango", false).collect(toList()) ); }