Change.java

  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. import java.math.BigDecimal;

  18. public class Change implements Comparable<Change> {

  19.   private BigDecimal id;
  20.   private String description;
  21.   private String appliedTimestamp;
  22.   private String filename;

  23.   public Change() {
  24.   }

  25.   public Change(BigDecimal id) {
  26.     this.id = id;
  27.   }

  28.   public Change(BigDecimal id, String appliedTimestamp, String description) {
  29.     this.id = id;
  30.     this.appliedTimestamp = appliedTimestamp;
  31.     this.description = description;
  32.   }

  33.   public Change(Change toCopy) {
  34.     this(toCopy.getId(), toCopy.getAppliedTimestamp(), toCopy.getDescription());
  35.     this.filename = toCopy.getFilename();
  36.   }

  37.   public BigDecimal getId() {
  38.     return id;
  39.   }

  40.   public void setId(BigDecimal id) {
  41.     this.id = id;
  42.   }

  43.   public String getDescription() {
  44.     return description;
  45.   }

  46.   public void setDescription(String description) {
  47.     this.description = description;
  48.   }

  49.   public String getAppliedTimestamp() {
  50.     return appliedTimestamp;
  51.   }

  52.   public void setAppliedTimestamp(String appliedTimestamp) {
  53.     this.appliedTimestamp = appliedTimestamp;
  54.   }

  55.   public String getFilename() {
  56.     return filename;
  57.   }

  58.   public void setFilename(String filename) {
  59.     this.filename = filename;
  60.   }

  61.   @Override
  62.   public String toString() {
  63.     return id + " " + (appliedTimestamp == null ? "   ...pending...   " : appliedTimestamp) + " " + description;
  64.   }

  65.   @Override
  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.     Change change = (Change) o;

  74.     return id.equals(change.getId());
  75.   }

  76.   @Override
  77.   public int hashCode() {
  78.     return id.hashCode();
  79.   }

  80.   @Override
  81.   public int compareTo(Change change) {
  82.     return id.compareTo(change.getId());
  83.   }

  84. }