diff options
author | 2016-11-14 04:14:29 +0700 | |
---|---|---|
committer | 2016-11-14 04:14:29 +0700 | |
commit | f3de17fa7152ccc7637709835a49a0a1baaa611e (patch) | |
tree | 2b655c5343c60278d4e75e47153795d77de1d872 /juick-core/src/main/java/com/juick/Tag.java | |
parent | e610c996f0107cf3c9dc489e67c1eaebfeb73551 (diff) |
some fields are finalized; equals() improvements
Diffstat (limited to 'juick-core/src/main/java/com/juick/Tag.java')
-rw-r--r-- | juick-core/src/main/java/com/juick/Tag.java | 19 |
1 files changed, 9 insertions, 10 deletions
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; } } |