com.github.jayield.rapper.unitofwork.UpdateHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rapper Show documentation
Show all versions of rapper Show documentation
Async DataMapper for JDBC
package com.github.jayield.rapper.unitofwork;
import com.github.jayield.rapper.DomainObject;
import java.util.Queue;
public class UpdateHelper extends AbstractCommitHelper {
private final Queue removedObjects;
public UpdateHelper(UnitOfWork unit, Queue dirtyObjects, Queue removedObjects) {
super(unit, dirtyObjects);
this.removedObjects = removedObjects;
}
@Override
public Object identityMapUpdateNext() {
if (objectIterator == null) objectIterator = list.iterator();
if (objectIterator.hasNext()) {
DomainObject object = objectIterator.next();
unit.validate(object.getIdentityKey(), object);
return true;
}
return null;
}
@Override
public Object rollbackNext() {
if (objectIterator == null) objectIterator = list.iterator();
if (objectIterator.hasNext()) {
DomainObject obj = objectIterator.next();
unit.invalidate(obj.getClass(), obj.getIdentityKey());
return true;
}
return null;
}
}