use of jetbrains.exodus.entitystore.iterate.ExcludeNullIterableDecorator in project xodus by JetBrains.
the class ExcludeNullStaticTypedEntityIterable method instantiate.
@Override
public Iterable<Entity> instantiate() {
Iterable<Entity> instantiatedDecorated = decorated.instantiate();
if (queryEngine.isPersistentIterable(instantiatedDecorated)) {
EntityIterableBase entityIterableBaseDecorated = ((EntityIterableBase) instantiatedDecorated).getSource();
if (entityIterableBaseDecorated == EntityIterableBase.EMPTY) {
return EntityIterableBase.EMPTY;
}
return queryEngine.wrap(new ExcludeNullIterableDecorator(entityIterableBaseDecorated.getTransaction(), entityIterableBaseDecorated));
}
return () -> new Iterator<Entity>() {
private Iterator<Entity> iterator = null;
private Entity next = null;
@Override
public boolean hasNext() {
if (next != null) {
return true;
}
if (iterator == null) {
iterator = decorated.iterator();
}
while (iterator.hasNext() && next == null) {
next = iterator.next();
}
return next != null;
}
@Override
public Entity next() {
if (hasNext()) {
Entity result = next;
next = null;
return result;
}
throw new NoSuchElementException();
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
Aggregations