From 4b6df5adfeb92cd09428e59a963a6ee56d7d28d6 Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Sun, 25 Jan 2015 14:39:20 +0000 Subject: SPIGOT-456: Provide equals & hashCode methods for CraftObjective and CraftTeam --- .../craftbukkit/scoreboard/CraftObjective.java | 21 +++++++++++++++++++++ .../bukkit/craftbukkit/scoreboard/CraftTeam.java | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java index 11713357..239ceca0 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftObjective.java @@ -113,4 +113,25 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective return getScoreboard(); } + + @Override + public int hashCode() { + int hash = 7; + hash = 31 * hash + (this.objective != null ? this.objective.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CraftObjective other = (CraftObjective) obj; + return !(this.objective != other.objective && (this.objective == null || !this.objective.equals(other.objective))); + } + + } diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java index 5584353b..c4db4621 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java @@ -194,4 +194,25 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { return getScoreboard(); } + + @Override + public int hashCode() { + int hash = 7; + hash = 43 * hash + (this.team != null ? this.team.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CraftTeam other = (CraftTeam) obj; + return !(this.team != other.team && (this.team == null || !this.team.equals(other.team))); + } + + } -- cgit v1.2.3