net.java.ao.schema.ddl.SQLAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of activeobjects-core Show documentation
Show all versions of activeobjects-core Show documentation
This is the core library for Active Objects. It is generic and can be embedded in any environment.
As such it is generic and won't contain all connection pooling, etc.
package net.java.ao.schema.ddl;
import java.util.Objects;
/**
* An SQL statement representing some stage of schema modification.
* This may optionally have a corresponding "undo" action which can be executed to roll
* back this modification; this will only be done if the modification succeeded but then
* some later action failed.
*/
public final class SQLAction {
private final String statement;
private final SQLAction undoAction;
private SQLAction(String statement, SQLAction undoAction) {
this.statement = Objects.requireNonNull(statement, "statement can't be null");
this.undoAction = undoAction;
}
public static SQLAction of(CharSequence statement) {
return new SQLAction(statement.toString(), null);
}
public SQLAction withUndoAction(SQLAction undoAction) {
return new SQLAction(this.statement, undoAction);
}
public String getStatement() {
return statement;
}
public SQLAction getUndoAction() {
return undoAction;
}
@Override
public String toString() {
return "SQLAction{" +
"statement='" + statement + '\'' +
", undoAction=" + undoAction +
'}';
}
}