SortedAttributeMetadata extends AttributeMetadata<A, O> { @Override public Stream<KeyValue<A, O>> getKeysAndValues() { return super.getKeysAndValues(); } 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 testGetKeysAndValues() { IndexedCollection<Car> cars = new ConcurrentIndexedCollection<>(); Car car1 = new Car(1, "Ford", "Taurus", Car.Color.GREEN, 4, 1000.0, emptyList(), Collections.emptyList()); Car car2 = new Car(2, "Toyota", "Prius", Car.Color.BLUE, 4, 2000.0, emptyList(), Collections.emptyList()); Car car3 = new Car(3, "Honda", "Civic", Car.Color.BLUE, 4, 2000.0, emptyList(), Collections.emptyList()); cars.addAll(asList(car1, car2, car3)); cars.addIndex(NavigableIndex.onAttribute(Car.MANUFACTURER)); MetadataEngine<Car> metadataEngine = cars.getMetadataEngine(); SortedAttributeMetadata<String, Car> attributeMetadata = metadataEngine.getSortedAttributeMetadata(Car.MANUFACTURER); assertEquals( asList(keyValue("Ford", car1), keyValue("Honda", car3), keyValue("Toyota", car2)), attributeMetadata.getKeysAndValues().collect(toList()) ); assertEquals( asList(keyValue("Ford", car1), keyValue("Honda", car3)), attributeMetadata.getKeysAndValues("Alpha", true, "Toyota", false).collect(toList()) ); }