1 | |
package liquibase.changelog; |
2 | |
|
3 | |
import liquibase.change.CheckSum; |
4 | |
|
5 | |
import java.util.Date; |
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
public class RanChangeSet { |
11 | |
private final String changeLog; |
12 | |
private final String id; |
13 | |
private final String author; |
14 | |
private final CheckSum lastCheckSum; |
15 | |
private final Date dateExecuted; |
16 | |
private String tag; |
17 | |
private ChangeSet.ExecType execType; |
18 | |
|
19 | |
public RanChangeSet(ChangeSet changeSet) { |
20 | 0 | this(changeSet, null); |
21 | 0 | } |
22 | |
|
23 | |
public RanChangeSet(ChangeSet changeSet, ChangeSet.ExecType execType) { |
24 | 0 | this(changeSet.getFilePath(), changeSet.getId(), changeSet.getAuthor(), changeSet.generateCheckSum(), |
25 | |
new Date(), null, execType); |
26 | 0 | } |
27 | |
|
28 | |
public RanChangeSet(String changeLog, String id, String author, CheckSum lastCheckSum, Date dateExecuted, |
29 | 13 | String tag, ChangeSet.ExecType execType) { |
30 | 13 | this.changeLog = changeLog; |
31 | 13 | this.id = id; |
32 | 13 | this.author = author; |
33 | 13 | this.lastCheckSum = lastCheckSum; |
34 | 13 | if (dateExecuted == null) { |
35 | 1 | this.dateExecuted = null; |
36 | |
} else { |
37 | 12 | this.dateExecuted = new Date(dateExecuted.getTime()); |
38 | |
} |
39 | 13 | this.tag = tag; |
40 | 13 | this.execType = execType; |
41 | 13 | } |
42 | |
|
43 | |
public String getChangeLog() { |
44 | 10 | return changeLog; |
45 | |
} |
46 | |
|
47 | |
public String getId() { |
48 | 20 | return id; |
49 | |
} |
50 | |
|
51 | |
public String getAuthor() { |
52 | 12 | return author; |
53 | |
} |
54 | |
|
55 | |
public CheckSum getLastCheckSum() { |
56 | 2 | return lastCheckSum; |
57 | |
} |
58 | |
|
59 | |
public Date getDateExecuted() { |
60 | 11 | if (dateExecuted == null) { |
61 | 1 | return null; |
62 | |
} |
63 | 10 | return (Date) dateExecuted.clone(); |
64 | |
} |
65 | |
|
66 | |
public String getTag() { |
67 | 3 | return tag; |
68 | |
} |
69 | |
|
70 | |
public void setTag(String tag) { |
71 | 0 | this.tag = tag; |
72 | 0 | } |
73 | |
|
74 | |
public ChangeSet.ExecType getExecType() { |
75 | 0 | return execType; |
76 | |
} |
77 | |
|
78 | |
@Override |
79 | |
public boolean equals(Object o) { |
80 | 0 | if (this == o) { |
81 | 0 | return true; |
82 | |
} |
83 | 0 | if (o == null || getClass() != o.getClass()) { |
84 | 0 | return false; |
85 | |
} |
86 | |
|
87 | 0 | final RanChangeSet that = (RanChangeSet) o; |
88 | |
|
89 | 0 | return author.equals(that.author) && changeLog.equals(that.changeLog) && id.equals(that.id); |
90 | |
|
91 | |
} |
92 | |
|
93 | |
@Override |
94 | |
public int hashCode() { |
95 | |
int result; |
96 | 0 | result = changeLog.hashCode(); |
97 | 0 | result = 29 * result + id.hashCode(); |
98 | 0 | result = 29 * result + author.hashCode(); |
99 | 0 | return result; |
100 | |
} |
101 | |
|
102 | |
public boolean isSameAs(ChangeSet changeSet) { |
103 | 0 | return this.getChangeLog().replace('\\', '/').equalsIgnoreCase(changeSet.getFilePath().replace('\\', '/')) |
104 | |
&& this.getId().equalsIgnoreCase(changeSet.getId()) |
105 | |
&& this.getAuthor().equalsIgnoreCase(changeSet.getAuthor()); |
106 | |
} |
107 | |
} |