01: package liquibase.preconditions;
02:
03: import liquibase.DatabaseChangeLog;
04: import liquibase.database.Database;
05: import liquibase.exception.PreconditionFailedException;
06:
07: import java.util.ArrayList;
08: import java.util.List;
09:
10: /**
11: * Container class for all preconditions on a change log.
12: */
13: public class AndPrecondition extends PreconditionLogic {
14:
15: public void check(Database database, DatabaseChangeLog changeLog)
16: throws PreconditionFailedException {
17: boolean allPassed = true;
18: List<FailedPrecondition> failures = new ArrayList<FailedPrecondition>();
19: for (Precondition precondition : getNestedPreconditions()) {
20: try {
21: precondition.check(database, changeLog);
22: } catch (PreconditionFailedException e) {
23: failures.addAll(e.getFailedPreconditions());
24: allPassed = false;
25: }
26: }
27: if (!allPassed) {
28: throw new PreconditionFailedException(failures);
29: }
30: }
31:
32: public String getTagName() {
33: return "and";
34: }
35: }
|