aboutsummaryrefslogtreecommitdiff
path: root/juick-core/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-14 04:14:29 +0700
committerGravatar Alexander Alexeev2016-11-14 04:14:29 +0700
commitf3de17fa7152ccc7637709835a49a0a1baaa611e (patch)
tree2b655c5343c60278d4e75e47153795d77de1d872 /juick-core/src/main/java/com/juick
parente610c996f0107cf3c9dc489e67c1eaebfeb73551 (diff)
some fields are finalized; equals() improvements
Diffstat (limited to 'juick-core/src/main/java/com/juick')
-rw-r--r--juick-core/src/main/java/com/juick/Message.java2
-rw-r--r--juick-core/src/main/java/com/juick/PM.java10
-rw-r--r--juick-core/src/main/java/com/juick/Recommendation.java9
-rw-r--r--juick-core/src/main/java/com/juick/Tag.java19
-rw-r--r--juick-core/src/main/java/com/juick/User.java7
5 files changed, 23 insertions, 24 deletions
diff --git a/juick-core/src/main/java/com/juick/Message.java b/juick-core/src/main/java/com/juick/Message.java
index 2c004f5a..8afd1d7b 100644
--- a/juick-core/src/main/java/com/juick/Message.java
+++ b/juick-core/src/main/java/com/juick/Message.java
@@ -29,9 +29,7 @@ import java.util.stream.Collectors;
* @author Ugnich Anton
*/
public class Message implements Comparable {
-
private int MID = 0;
-
private int RID = 0;
@JsonProperty("replyto")
diff --git a/juick-core/src/main/java/com/juick/PM.java b/juick-core/src/main/java/com/juick/PM.java
index 658cafc9..4686b34a 100644
--- a/juick-core/src/main/java/com/juick/PM.java
+++ b/juick-core/src/main/java/com/juick/PM.java
@@ -4,13 +4,13 @@ package com.juick;
* Created by vt on 08/02/16.
*/
public class PM {
- private User to;
-
- public User getTo() {
- return to;
- }
+ private final User to;
public PM(User to) {
this.to = to;
}
+
+ public User getTo() {
+ return to;
+ }
}
diff --git a/juick-core/src/main/java/com/juick/Recommendation.java b/juick-core/src/main/java/com/juick/Recommendation.java
index 4cfa67c2..1ae41771 100644
--- a/juick-core/src/main/java/com/juick/Recommendation.java
+++ b/juick-core/src/main/java/com/juick/Recommendation.java
@@ -4,13 +4,14 @@ package com.juick;
* Created by vt on 08/02/16.
*/
public class Recommendation {
- User from;
+ private final User from;
- public User getFrom() {
- return from;
- }
public Recommendation(User from) {
this.from = from;
}
+
+ public User getFrom() {
+ return from;
+ }
}
diff --git a/juick-core/src/main/java/com/juick/Tag.java b/juick-core/src/main/java/com/juick/Tag.java
index 8b790377..fa518e84 100644
--- a/juick-core/src/main/java/com/juick/Tag.java
+++ b/juick-core/src/main/java/com/juick/Tag.java
@@ -23,35 +23,34 @@ import com.fasterxml.jackson.annotation.JsonValue;
import java.util.Objects;
/**
- *
* @author Ugnich Anton
*/
public class Tag {
+ private final String name;
- private String Name;
public int TID = 0;
public int SynonymID = 0;
public int UsageCnt = 0;
+
public Tag(String name) {
- this.Name = name;
+ this.name = name;
}
@Override
public boolean equals(Object o) {
- boolean equal = false;
- if (o != null && o instanceof Tag) {
- equal = Objects.equals(Name, ((Tag) o).Name);
- }
- return equal;
+ return o == this ||
+ (o instanceof Tag) && Objects.equals(name, ((Tag) o).name);
}
+
@JsonIgnore
public String getName() {
- return Name;
+ return name;
}
+
@Override
@JsonValue
public String toString() {
- return Name;
+ return name;
}
}
diff --git a/juick-core/src/main/java/com/juick/User.java b/juick-core/src/main/java/com/juick/User.java
index a8109e50..b8936bab 100644
--- a/juick-core/src/main/java/com/juick/User.java
+++ b/juick-core/src/main/java/com/juick/User.java
@@ -21,11 +21,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
- *
* @author Ugnich Anton
*/
public class User {
-
private int UID = 0;
private String UName = null;
@JsonIgnore
@@ -53,7 +51,8 @@ public class User {
@Override
public boolean equals(Object obj) {
- return (obj instanceof User && ((User) obj).getUID() == this.getUID());
+ return obj == this ||
+ (obj instanceof User && ((User) obj).getUID() == this.getUID());
}
@JsonProperty("uid")
@@ -100,10 +99,12 @@ public class User {
public void setAuthHash(String authHash) {
AuthHash = authHash;
}
+
@JsonProperty("unreadCount")
public Integer getUnreadCount() {
return MessagesCount;
}
+
public void setUnreadCount(Integer count) {
MessagesCount = count;
}