From f386d47c66dd8cf69bb03972ed44d812b8f24761 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 4 May 2018 22:35:19 +0300 Subject: common: add missing hashCode() to core entities --- juick-common/src/main/java/com/juick/Message.java | 6 ++++++ juick-common/src/main/java/com/juick/Tag.java | 5 +++++ juick-common/src/main/java/com/juick/User.java | 8 +++----- 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'juick-common/src/main/java/com/juick') diff --git a/juick-common/src/main/java/com/juick/Message.java b/juick-common/src/main/java/com/juick/Message.java index 45a0fdd4..b462e9b2 100644 --- a/juick-common/src/main/java/com/juick/Message.java +++ b/juick-common/src/main/java/com/juick/Message.java @@ -29,6 +29,7 @@ import java.time.Instant; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Set; /** @@ -317,4 +318,9 @@ public class Message implements Comparable { public void setReactions(Set reactions) { this.reactions = reactions; } + + @Override + public int hashCode() { + return Objects.hash(mid, rid); + } } diff --git a/juick-common/src/main/java/com/juick/Tag.java b/juick-common/src/main/java/com/juick/Tag.java index 29e5c767..b93d0e76 100644 --- a/juick-common/src/main/java/com/juick/Tag.java +++ b/juick-common/src/main/java/com/juick/Tag.java @@ -56,6 +56,11 @@ public class Tag implements Comparable { return name; } + @Override + public int hashCode() { + return Objects.hash(name); + } + @Override public String toString() { return name; diff --git a/juick-common/src/main/java/com/juick/User.java b/juick-common/src/main/java/com/juick/User.java index 478c6a48..5edfe782 100644 --- a/juick-common/src/main/java/com/juick/User.java +++ b/juick-common/src/main/java/com/juick/User.java @@ -18,7 +18,6 @@ package com.juick; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import javax.annotation.Nonnull; @@ -29,13 +28,14 @@ import javax.xml.bind.annotation.XmlTransient; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @author Ugnich Anton */ @XmlRootElement(name = "user", namespace = "http://juick.com/user") @XmlAccessorType() -public class User implements Serializable { +public class User { private int uid; private String name; private Object avatar; @@ -59,9 +59,7 @@ public class User implements Serializable { @Override public int hashCode() { - return new HashCodeBuilder() - .append(getUid()) - .toHashCode(); + return Objects.hash(uid); } @Override -- cgit v1.2.3