SQLiteIndex extends AbstractAttributeIndex<A, O> implements SortedKeyStatisticsAttributeIndex<A, O>, NonHeapTypeIndex { static <O, K> Iterable<K> objectKeyIterable(final Iterable<O> objects, final SimpleAttribute<O, K> primaryKeyAttribute, final QueryOptions queryOptions){ return new Iterable<K>() { @Override public Iterator<K> iterator() { return new UnmodifiableIterator<K>() { final Iterator<O> iterator = objects.iterator(); @Override public boolean hasNext() { return iterator.hasNext(); } @Override public K next() { O next = iterator.next(); return primaryKeyAttribute.getValue(next, queryOptions); } }; } }; } SQLiteIndex(final Attribute<O, A> attribute,
                       final SimpleAttribute<O, K> primaryKeyAttribute,
                       final SimpleAttribute<K, O> foreignKeyAttribute,
                       final String tableNameSuffix); @Override boolean supportsQuery(Query<O> query, QueryOptions queryOptions); @Override boolean isMutable(); @Override boolean isQuantized(); @Override Index<O> getEffectiveIndex(); @Override ResultSet<O> retrieve(final Query<O> query, final QueryOptions queryOptions); @Override boolean addAll(final ObjectSet<O> objectSet, final QueryOptions queryOptions); @Override boolean removeAll(final ObjectSet<O> objectSet, final QueryOptions queryOptions); @Override void clear(QueryOptions queryOptions); @Override void init(ObjectStore<O> objectStore, QueryOptions queryOptions); @Override void destroy(QueryOptions queryOptions); @Override CloseableIterable<A> getDistinctKeys(final QueryOptions queryOptions); @Override CloseableIterable<A> getDistinctKeys(A lowerBound, boolean lowerInclusive, A upperBound, boolean upperInclusive, final QueryOptions queryOptions); @Override CloseableIterable<A> getDistinctKeysDescending(QueryOptions queryOptions); @Override CloseableIterable<A> getDistinctKeysDescending(A lowerBound, boolean lowerInclusive, A upperBound, boolean upperInclusive, QueryOptions queryOptions); @Override Integer getCountOfDistinctKeys(QueryOptions queryOptions); @Override CloseableIterable<KeyStatistics<A>> getStatisticsForDistinctKeysDescending(QueryOptions queryOptions); @Override CloseableIterable<KeyStatistics<A>> getStatisticsForDistinctKeys(QueryOptions queryOptions); @Override CloseableIterable<KeyValue<A, O>> getKeysAndValues(final QueryOptions queryOptions); @Override CloseableIterable<KeyValue<A, O>> getKeysAndValues(A lowerBound, boolean lowerInclusive, A upperBound, boolean upperInclusive, final QueryOptions queryOptions); @Override CloseableIterable<KeyValue<A, O>> getKeysAndValuesDescending(QueryOptions queryOptions); @Override CloseableIterable<KeyValue<A, O>> getKeysAndValuesDescending(A lowerBound, boolean lowerInclusive, A upperBound, boolean upperInclusive, QueryOptions queryOptions); @Override Integer getCountForKey(A key, QueryOptions queryOptions); @Override boolean equals(Object o); @Override int hashCode(); static SQLiteIndex<A, O, K> onAttribute(final Attribute<O, A> attribute,
                                                                                   final SimpleAttribute<O, K> objectKeyAttribute,
                                                                                   final SimpleAttribute<K, O> foreignKeyAttribute);  }
@Test public void testObjectKeyIterable(){ Iterable<Integer> objectKeys = SQLiteIndex.objectKeyIterable(data, Car.CAR_ID, null); assertNotNull(objectKeys); Iterator<Integer> objectKeysIterator = objectKeys.iterator(); assertNotNull(objectKeysIterator); assertTrue(objectKeysIterator.hasNext()); assertEquals(new Integer(1), objectKeysIterator.next()); assertTrue(objectKeysIterator.hasNext()); assertEquals(new Integer(2), objectKeysIterator.next()); assertTrue(objectKeysIterator.hasNext()); assertEquals(new Integer(3), objectKeysIterator.next()); assertTrue(objectKeysIterator.hasNext()); assertEquals(new Integer(4), objectKeysIterator.next()); assertTrue(objectKeysIterator.hasNext()); assertEquals(new Integer(5), objectKeysIterator.next()); assertFalse(objectKeysIterator.hasNext()); }