class FilteredObjectStore implements ObjectStore<O> {

    @Override
    public CloseableIterator<O> iterator(QueryOptions queryOptions) {
        final CloseableIterator<O> backingIterator = backingObjectStore.iterator(queryOptions);
        final FilteringIterator<O> filteringIterator = new FilteringIterator<O>(backingIterator, queryOptions) {
            @Override
            public boolean isValid(O object, QueryOptions queryOptions) {
                return filterQuery.matches(object, queryOptions);
            }
        };
        return new CloseableIterator<O>() {
            @Override
            public void close() {
                backingIterator.close();
            }

            @Override
            public boolean hasNext() {
                return filteringIterator.hasNext();
            }

            @Override
            public O next() {
                return filteringIterator.next();
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException("Modification not supported");
            }
        };
    }

    public  FilteredObjectStore(ObjectStore<O> backingObjectStore, Query<O> filterQuery);

}