01: package liquibase.preconditions;
02:
03: import liquibase.DatabaseChangeLog;
04: import liquibase.database.Database;
05: import liquibase.exception.PreconditionFailedException;
06:
07: /**
08: * Class for controling "not" logic in preconditions.
09: */
10: public class NotPrecondition extends PreconditionLogic {
11:
12: public void check(Database database, DatabaseChangeLog changeLog)
13: throws PreconditionFailedException {
14: for (Precondition precondition : getNestedPreconditions()) {
15: boolean threwException = false;
16: try {
17: precondition.check(database, changeLog);
18: } catch (PreconditionFailedException e) {
19: ; //that's what we want with a Not precondition
20: threwException = true;
21: }
22:
23: if (!threwException) {
24: throw new PreconditionFailedException(
25: "Not precondition failed", changeLog, this );
26: }
27: }
28: }
29:
30: public String getTagName() {
31: return "not";
32: }
33: }
|