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

com.github.jayield.rapper.unitofwork.UpdateHelper Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy