From 5cfd7a1b2a04847ac64ace7ed21e10a4bb8981d4 Mon Sep 17 00:00:00 2001 From: 502647092 Date: Mon, 19 Sep 2016 15:56:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=98=BB=E6=96=AD?= =?UTF-8?q?=E6=80=A7=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- src/main/java/pw/yumc/YumCore/commands/CommandInfo.java | 8 ++++++++ src/main/java/pw/yumc/YumCore/commands/TabInfo.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/java/pw/yumc/YumCore/commands/CommandInfo.java b/src/main/java/pw/yumc/YumCore/commands/CommandInfo.java index cdab42e..eceee23 100644 --- a/src/main/java/pw/yumc/YumCore/commands/CommandInfo.java +++ b/src/main/java/pw/yumc/YumCore/commands/CommandInfo.java @@ -92,6 +92,9 @@ public class CommandInfo { @Override public boolean equals(final Object obj) { + if (this == obj) { + return true; + } if (obj instanceof CommandInfo) { return name.equalsIgnoreCase(((CommandInfo) obj).getName()); } @@ -157,6 +160,11 @@ public class CommandInfo { return sort; } + @Override + public int hashCode() { + return name.toLowerCase().hashCode() + method.hashCode() + origin.hashCode(); + } + /** * @return 是否为异步命令 */ diff --git a/src/main/java/pw/yumc/YumCore/commands/TabInfo.java b/src/main/java/pw/yumc/YumCore/commands/TabInfo.java index 0550188..7e8da3e 100644 --- a/src/main/java/pw/yumc/YumCore/commands/TabInfo.java +++ b/src/main/java/pw/yumc/YumCore/commands/TabInfo.java @@ -44,6 +44,9 @@ public class TabInfo { @Override public boolean equals(final Object obj) { + if (this == obj) { + return true; + } if (obj instanceof TabInfo) { return method.equals(((TabInfo) obj).getMethod()); } @@ -76,4 +79,9 @@ public class TabInfo { public Method getMethod() { return method; } + + @Override + public int hashCode() { + return method.hashCode() + origin.hashCode(); + } }