Merge pull request elastic/elasticsearch#1495 from nik9000/checkstyle_equals_hashcode

Implement hashCode where we implement equals

Original commit: elastic/x-pack-elasticsearch@2f7a2db799
This commit is contained in:
Nik Everett 2016-02-09 22:00:45 -05:00
commit 46558ee3f7
5 changed files with 20 additions and 3 deletions

View File

@ -5,7 +5,4 @@
<suppressions>
<!-- On Windows, Checkstyle matches files using \ path separator -->
<!-- Hopefully temporary suppression of LineLength on files that don't pass it. We should remove these when we the
files start to pass. -->
<!-- -->
</suppressions>

View File

@ -32,6 +32,11 @@ public class SystemUser extends User {
return o == INSTANCE;
}
@Override
public int hashCode() {
return System.identityHashCode(this);
}
public static boolean is(User user) {
return INSTANCE.equals(user);
}

View File

@ -68,6 +68,11 @@ public class XPackUser extends User {
return INSTANCE == o;
}
@Override
public int hashCode() {
return System.identityHashCode(this);
}
public static boolean is(User user) {
return INSTANCE.equals(user);
}

View File

@ -35,4 +35,9 @@ public class ExecutableAlwaysCondition extends ExecutableCondition<AlwaysConditi
return obj instanceof ExecutableAlwaysCondition;
}
@Override
public int hashCode() {
// All instances has to produce the same hashCode because they are all equal
return 0;
}
}

View File

@ -35,4 +35,9 @@ public class ExecutableNeverCondition extends ExecutableCondition<NeverCondition
return obj instanceof ExecutableNeverCondition;
}
@Override
public int hashCode() {
// All instances has to produce the same hashCode because they are all equal
return 0;
}
}