
io.ebean.common.ModifyIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebean.common;
import io.ebean.bean.BeanCollection;
import java.util.Iterator;
/**
* Wraps an iterator for the purposes of notifying removals and additions to the
* BeanCollection owner.
*
* This is required for persisting ManyToMany objects. Additions and removals
* become inserts and deletes to the intersection table.
*
*/
class ModifyIterator implements Iterator {
private final BeanCollection owner;
private final Iterator it;
private E last;
/**
* Create with an Owner and the underlying Iterator this wraps.
*
* The owner is notified of the removals.
*
*/
ModifyIterator(BeanCollection owner, Iterator it) {
this.owner = owner;
this.it = it;
}
@Override
public boolean hasNext() {
return it.hasNext();
}
@Override
public E next() {
last = it.next();
return last;
}
@Override
public void remove() {
owner.modifyRemoval(last);
it.remove();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy