All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebean.common.ModifyIterator Maven / Gradle / Ivy

There is a newer version: 15.6.0
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy