]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10085 BranchDto and SnapshotDto have equals hashCode & toString
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 15 Nov 2017 15:28:35 +0000 (16:28 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 24 Nov 2017 08:23:58 +0000 (09:23 +0100)
server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDto.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/SnapshotDto.java

index 65b46912c6d613ce7001163378487d15b51e8cb0..4126de067ca4394141f0068831e67743bcf0c57b 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.db.component;
 
+import java.util.Objects;
 import javax.annotation.Nullable;
 
 import static com.google.common.base.Preconditions.checkArgument;
@@ -133,6 +134,27 @@ public class BranchDto {
     return this;
   }
 
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    BranchDto branchDto = (BranchDto) o;
+    return Objects.equals(uuid, branchDto.uuid) &&
+        Objects.equals(projectUuid, branchDto.projectUuid) &&
+        Objects.equals(kee, branchDto.kee) &&
+        branchType == branchDto.branchType &&
+        Objects.equals(mergeBranchUuid, branchDto.mergeBranchUuid);
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(uuid, projectUuid, kee, branchType, mergeBranchUuid);
+  }
+
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder("BranchDto{");
index 1dfec6f1b93ce0f30730dc412e3c44c1a1b33572..46315d8d6239df39f4994ff78289808afac7acd9 100644 (file)
@@ -19,6 +19,7 @@
  */
 package org.sonar.db.component;
 
+import java.util.Objects;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 
@@ -168,4 +169,50 @@ public final class SnapshotDto {
   public Long getCreatedAt() {
     return createdAt;
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    SnapshotDto that = (SnapshotDto) o;
+    return Objects.equals(id, that.id) &&
+      Objects.equals(uuid, that.uuid) &&
+      Objects.equals(componentUuid, that.componentUuid) &&
+      Objects.equals(createdAt, that.createdAt) &&
+      Objects.equals(buildDate, that.buildDate) &&
+      Objects.equals(status, that.status) &&
+      Objects.equals(purgeStatus, that.purgeStatus) &&
+      Objects.equals(last, that.last) &&
+      Objects.equals(version, that.version) &&
+      Objects.equals(periodMode, that.periodMode) &&
+      Objects.equals(periodParam, that.periodParam) &&
+      Objects.equals(periodDate, that.periodDate);
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(id, uuid, componentUuid, createdAt, buildDate, status, purgeStatus, last, version, periodMode, periodParam, periodDate);
+  }
+
+  @Override
+  public String toString() {
+    return "SnapshotDto{" +
+      "id=" + id +
+      ", uuid='" + uuid + '\'' +
+      ", componentUuid='" + componentUuid + '\'' +
+      ", createdAt=" + createdAt +
+      ", buildDate=" + buildDate +
+      ", status='" + status + '\'' +
+      ", purgeStatus=" + purgeStatus +
+      ", last=" + last +
+      ", version='" + version + '\'' +
+      ", periodMode='" + periodMode + '\'' +
+      ", periodParam='" + periodParam + '\'' +
+      ", periodDate=" + periodDate +
+      '}';
+  }
 }