mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
* no effective code change: add missing @override in "io.ebean.*" package * no effective code change: add missing @override in "io.ebeaninternal.api.*" package * no effective code change: add missing @override in "io.ebeaninternal.server.*" package * no effective code change: add missing @override in "io.ebeaninternal.util.*" package * no effective code change: add missing @override in "io.ebeanservice.*" package * no effective code change: add missing @override in "src/test/java/"
52 lines
987 B
Java
52 lines
987 B
Java
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.
|
|
* <p>
|
|
* This is required for persisting ManyToMany objects. Additions and removals
|
|
* become inserts and deletes to the intersection table.
|
|
* </p>
|
|
*/
|
|
class ModifyIterator<E> implements Iterator<E> {
|
|
|
|
private final BeanCollection<E> owner;
|
|
|
|
private final Iterator<E> it;
|
|
|
|
private E last;
|
|
|
|
/**
|
|
* Create with an Owner and the underlying Iterator this wraps.
|
|
* <p>
|
|
* The owner is notified of the removals.
|
|
* </p>
|
|
*/
|
|
ModifyIterator(BeanCollection<E> owner, Iterator<E> 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();
|
|
}
|
|
|
|
}
|