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

com.avaje.ebean.common.ModifyIterator Maven / Gradle / Ivy

There is a newer version: 8.1.1
Show newest version
package com.avaje.ebean.common;

import java.util.Iterator;

import com.avaje.ebean.bean.BeanCollection;

/**
 * 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; } public boolean hasNext() { return it.hasNext(); } public E next() { last = it.next(); return last; } public void remove() { owner.modifyRemoval(last); it.remove(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy