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:
@@ -53,27 +53,25 @@ public final class JaasGrantedAuthority implements GrantedAuthority {
|
||||
return this.role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.principal.hashCode();
|
||||
result = 31 * result + this.role.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof JaasGrantedAuthority) {
|
||||
JaasGrantedAuthority jga = (JaasGrantedAuthority) obj;
|
||||
return this.role.equals(jga.role) && this.principal.equals(jga.principal);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = this.principal.hashCode();
|
||||
result = 31 * result + this.role.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Jaas Authority [" + this.role + "," + this.principal + "]";
|
||||
|
||||
@@ -62,18 +62,17 @@ public class InMemoryResource extends AbstractResource {
|
||||
return new ByteArrayInputStream(this.source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object res) {
|
||||
if (!(res instanceof InMemoryResource)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Arrays.equals(this.source, ((InMemoryResource) res).source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user