Refactor equals method
Using the accessor method for fields instead of directly access
This commit is contained in:
committed by
Josh Cummings
parent
8df8d4022e
commit
bcd4dcc15c
+2
-3
@@ -58,9 +58,8 @@ public final class JaasGrantedAuthority implements GrantedAuthority {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof JaasGrantedAuthority) {
|
||||
JaasGrantedAuthority jga = (JaasGrantedAuthority) obj;
|
||||
return this.role.equals(jga.role) && this.principal.equals(jga.principal);
|
||||
if (obj instanceof JaasGrantedAuthority jga) {
|
||||
return this.role.equals(jga.getAuthority()) && this.principal.equals(jga.getPrincipal());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,8 +50,8 @@ public final class SimpleGrantedAuthority implements GrantedAuthority {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof SimpleGrantedAuthority) {
|
||||
return this.role.equals(((SimpleGrantedAuthority) obj).role);
|
||||
if (obj instanceof SimpleGrantedAuthority sga) {
|
||||
return this.role.equals(sga.getAuthority());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user