1
0
mirror of synced 2026-05-22 21:33:16 +00:00

Use consistent equals/hashCode/toString order

Ensure that `equals` `hashCode` and `toString` methods always appear in
the same order. This aligns with the style used in Spring Framework.

Issue gh-8945
This commit is contained in:
Phillip Webb
2020-07-29 20:03:19 -07:00
committed by Rob Winch
parent 612fb22a7f
commit ec6a4cb3f0
12 changed files with 95 additions and 111 deletions
@@ -52,18 +52,25 @@ public abstract class AbstractPermission implements Permission {
}
@Override
public final boolean equals(Object arg0) {
if (arg0 == null) {
public final boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(arg0 instanceof Permission)) {
if (!(obj instanceof Permission)) {
return false;
}
Permission other = (Permission) obj;
return (this.mask == other.getMask());
}
Permission rhs = (Permission) arg0;
@Override
public final int hashCode() {
return this.mask;
}
return (this.mask == rhs.getMask());
@Override
public final String toString() {
return this.getClass().getSimpleName() + "[" + getPattern() + "=" + this.mask + "]";
}
@Override
@@ -76,14 +83,4 @@ public abstract class AbstractPermission implements Permission {
return AclFormattingUtils.printBinary(this.mask, this.code);
}
@Override
public final String toString() {
return this.getClass().getSimpleName() + "[" + getPattern() + "=" + this.mask + "]";
}
@Override
public final int hashCode() {
return this.mask;
}
}