summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-01-12 20:30:47 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-01-12 20:30:47 +0100
commit9642ddd2ce07eaea03319a10fdf96c3683b934f1 (patch)
treefdac913118d4e7b679ae8aa018b2e1e0a30c6183 /src
parent571fd8525478424e1aa328b3170fc0804b2d33fc (diff)
Implement equals() and hashCode for composite ID classes.
Change-Id: I7fd6be62f62f8dc43fa2863f52287654d307e8e0
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/mulk/mulkcms2/entity/ArticleBranchTipPK.java18
-rw-r--r--src/main/java/eu/mulk/mulkcms2/entity/ArticleRevisionCharacteristicPK.java19
2 files changed, 37 insertions, 0 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/entity/ArticleBranchTipPK.java b/src/main/java/eu/mulk/mulkcms2/entity/ArticleBranchTipPK.java
index 2508f87..6472a8d 100644
--- a/src/main/java/eu/mulk/mulkcms2/entity/ArticleBranchTipPK.java
+++ b/src/main/java/eu/mulk/mulkcms2/entity/ArticleBranchTipPK.java
@@ -1,6 +1,7 @@
package eu.mulk.mulkcms2.entity;
import java.io.Serializable;
+import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Id;
@@ -28,4 +29,21 @@ public class ArticleBranchTipPK implements Serializable {
public void setRevisionId(int revisionId) {
this.revisionId = revisionId;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof ArticleBranchTipPK)) {
+ return false;
+ }
+ ArticleBranchTipPK that = (ArticleBranchTipPK) o;
+ return articleId == that.articleId && revisionId == that.revisionId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(articleId, revisionId);
+ }
}
diff --git a/src/main/java/eu/mulk/mulkcms2/entity/ArticleRevisionCharacteristicPK.java b/src/main/java/eu/mulk/mulkcms2/entity/ArticleRevisionCharacteristicPK.java
index 2da588e..edaaff1 100644
--- a/src/main/java/eu/mulk/mulkcms2/entity/ArticleRevisionCharacteristicPK.java
+++ b/src/main/java/eu/mulk/mulkcms2/entity/ArticleRevisionCharacteristicPK.java
@@ -1,6 +1,7 @@
package eu.mulk.mulkcms2.entity;
import java.io.Serializable;
+import java.util.Objects;
import javax.persistence.Id;
public class ArticleRevisionCharacteristicPK implements Serializable {
@@ -24,4 +25,22 @@ public class ArticleRevisionCharacteristicPK implements Serializable {
public void setArticleRevisionId(int articleRevisionId) {
this.articleRevisionId = articleRevisionId;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof ArticleRevisionCharacteristicPK)) {
+ return false;
+ }
+ ArticleRevisionCharacteristicPK that = (ArticleRevisionCharacteristicPK) o;
+ return articleRevisionId == that.articleRevisionId
+ && Objects.equals(characteristic, that.characteristic);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(characteristic, articleRevisionId);
+ }
}