liquibase.changelog.visitor.ExpectedChangesVisitor Maven / Gradle / Ivy
package liquibase.changelog.visitor;
import liquibase.changelog.ChangeSet;
import liquibase.changelog.DatabaseChangeLog;
import liquibase.changelog.RanChangeSet;
import liquibase.changelog.filter.ChangeSetFilterResult;
import liquibase.database.Database;
import liquibase.exception.LiquibaseException;
import java.util.*;
public class ExpectedChangesVisitor implements ChangeSetVisitor {
private final LinkedHashSet unexpectedChangeSets;
public ExpectedChangesVisitor(List ranChangeSetList) {
this.unexpectedChangeSets = new LinkedHashSet<>(ranChangeSetList);
}
@Override
public Direction getDirection() {
return ChangeSetVisitor.Direction.FORWARD;
}
@Override
public void visit(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database, Set filterResults) throws LiquibaseException {
for (Iterator i = unexpectedChangeSets.iterator(); i.hasNext(); ) {
RanChangeSet ranChangeSet = i.next();
if (ranChangeSet.isSameAs(changeSet)) {
i.remove();
}
}
}
public Collection getUnexpectedChangeSets() {
return unexpectedChangeSets;
}
}