01: package liquibase;
02:
03: import java.util.Date;
04:
05: /**
06: * Encapsulates information about a previously-ran change set. Used to build rollback statements.
07: */
08: public class RanChangeSet {
09: private final String changeLog;
10: private final String id;
11: private final String author;
12: private final String md5sum;
13: private final Date dateExecuted;
14: private String tag;
15:
16: public RanChangeSet(ChangeSet changeSet) {
17: this (changeSet.getFilePath(), changeSet.getId(), changeSet
18: .getAuthor(), changeSet.getMd5sum(), new Date(), null);
19: }
20:
21: public RanChangeSet(String changeLog, String id, String author,
22: String md5sum, Date dateExecuted, String tag) {
23: this .changeLog = changeLog;
24: this .id = id;
25: this .author = author;
26: this .md5sum = md5sum;
27: if (dateExecuted == null) {
28: this .dateExecuted = null;
29: } else {
30: this .dateExecuted = new Date(dateExecuted.getTime());
31: }
32: this .tag = tag;
33: }
34:
35: public String getChangeLog() {
36: return changeLog;
37: }
38:
39: public String getId() {
40: return id;
41: }
42:
43: public String getAuthor() {
44: return author;
45: }
46:
47: public String getMd5sum() {
48: return md5sum;
49: }
50:
51: public Date getDateExecuted() {
52: if (dateExecuted == null) {
53: return null;
54: }
55: return (Date) dateExecuted.clone();
56: }
57:
58: public String getTag() {
59: return tag;
60: }
61:
62: public void setTag(String tag) {
63: this .tag = tag;
64: }
65:
66: public boolean equals(Object o) {
67: if (this == o) {
68: return true;
69: }
70: if (o == null || getClass() != o.getClass()) {
71: return false;
72: }
73:
74: final RanChangeSet that = (RanChangeSet) o;
75:
76: return author.equals(that.author)
77: && changeLog.equals(that.changeLog)
78: && id.equals(that.id);
79:
80: }
81:
82: public int hashCode() {
83: int result;
84: result = changeLog.hashCode();
85: result = 29 * result + id.hashCode();
86: result = 29 * result + author.hashCode();
87: return result;
88: }
89:
90: public boolean isSameAs(ChangeSet changeSet) {
91: return this .getChangeLog().replace('\\', '/').equals(
92: changeSet.getFilePath().replace('\\', '/'))
93: && this.getId().equals(changeSet.getId())
94: && this.getAuthor().equals(changeSet.getAuthor());
95: }
96: }
|