View Javadoc
1   /*
2    *    Copyright 2010-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.migration;
17  
18  import java.math.BigDecimal;
19  
20  public class Change implements Comparable<Change> {
21  
22    private BigDecimal id;
23    private String description;
24    private String appliedTimestamp;
25    private String filename;
26  
27    public Change() {
28    }
29  
30    public Change(BigDecimal id) {
31      this.id = id;
32    }
33  
34    public Change(BigDecimal id, String appliedTimestamp, String description) {
35      this.id = id;
36      this.appliedTimestamp = appliedTimestamp;
37      this.description = description;
38    }
39  
40    public Change(Change toCopy) {
41      this(toCopy.getId(), toCopy.getAppliedTimestamp(), toCopy.getDescription());
42      this.filename = toCopy.getFilename();
43    }
44  
45    public BigDecimal getId() {
46      return id;
47    }
48  
49    public void setId(BigDecimal id) {
50      this.id = id;
51    }
52  
53    public String getDescription() {
54      return description;
55    }
56  
57    public void setDescription(String description) {
58      this.description = description;
59    }
60  
61    public String getAppliedTimestamp() {
62      return appliedTimestamp;
63    }
64  
65    public void setAppliedTimestamp(String appliedTimestamp) {
66      this.appliedTimestamp = appliedTimestamp;
67    }
68  
69    public String getFilename() {
70      return filename;
71    }
72  
73    public void setFilename(String filename) {
74      this.filename = filename;
75    }
76  
77    @Override
78    public String toString() {
79      return id + " " + (appliedTimestamp == null ? "   ...pending...   " : appliedTimestamp) + " " + description;
80    }
81  
82    @Override
83    public boolean equals(Object o) {
84      if (this == o) {
85        return true;
86      }
87      if (o == null || getClass() != o.getClass()) {
88        return false;
89      }
90  
91      Change change = (Change) o;
92  
93      return id.equals(change.getId());
94    }
95  
96    @Override
97    public int hashCode() {
98      return id.hashCode();
99    }
100 
101   @Override
102   public int compareTo(Change change) {
103     return id.compareTo(change.getId());
104   }
105 
106 }