Using modern Java features
This commit is contained in:
committed by
Josh Cummings
parent
7e01ebdd92
commit
9b603b99ab
@@ -48,10 +48,9 @@ public class RequestKey {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof RequestKey)) {
|
||||
if (!(obj instanceof RequestKey key)) {
|
||||
return false;
|
||||
}
|
||||
RequestKey key = (RequestKey) obj;
|
||||
if (!this.url.equals(key.url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ public class TokenBasedRememberMeServices extends AbstractRememberMeServices {
|
||||
|
||||
private long getTokenExpiryTime(String[] cookieTokens) {
|
||||
try {
|
||||
return new Long(cookieTokens[1]);
|
||||
return Long.valueOf(cookieTokens[1]);
|
||||
}
|
||||
catch (NumberFormatException nfe) {
|
||||
throw new InvalidCookieException(
|
||||
|
||||
+1
-1
@@ -385,7 +385,7 @@ public class DigestAuthenticationFilter extends GenericFilterBean implements Mes
|
||||
}
|
||||
// Extract expiry time from nonce
|
||||
try {
|
||||
this.nonceExpiryTime = new Long(nonceTokens[0]);
|
||||
this.nonceExpiryTime = Long.valueOf(nonceTokens[0]);
|
||||
}
|
||||
catch (NumberFormatException nfe) {
|
||||
throw new BadCredentialsException(DigestAuthenticationFilter.this.messages.getMessage(
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class ServerFormLoginAuthenticationConverter implements Function<ServerWe
|
||||
@Override
|
||||
@Deprecated
|
||||
public Mono<Authentication> apply(ServerWebExchange exchange) {
|
||||
return exchange.getFormData().map((data) -> createAuthentication(data));
|
||||
return exchange.getFormData().map(this::createAuthentication);
|
||||
}
|
||||
|
||||
private UsernamePasswordAuthenticationToken createAuthentication(MultiValueMap<String, String> data) {
|
||||
|
||||
+1
-2
@@ -277,8 +277,7 @@ public class SwitchUserWebFilter implements WebFilter {
|
||||
private Optional<Authentication> extractSourceAuthentication(Authentication currentAuthentication) {
|
||||
// iterate over granted authorities and find the 'switch user' authority
|
||||
for (GrantedAuthority authority : currentAuthentication.getAuthorities()) {
|
||||
if (authority instanceof SwitchUserGrantedAuthority) {
|
||||
SwitchUserGrantedAuthority switchAuthority = (SwitchUserGrantedAuthority) authority;
|
||||
if (authority instanceof SwitchUserGrantedAuthority switchAuthority) {
|
||||
return Optional.of(switchAuthority.getSource());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ThrowableAnalyzer {
|
||||
*
|
||||
* @see Throwable#getCause()
|
||||
*/
|
||||
public static final ThrowableCauseExtractor DEFAULT_EXTRACTOR = (throwable) -> throwable.getCause();
|
||||
public static final ThrowableCauseExtractor DEFAULT_EXTRACTOR = Throwable::getCause;
|
||||
|
||||
/**
|
||||
* Default extractor for {@link InvocationTargetException} instances.
|
||||
|
||||
+1
-2
@@ -226,10 +226,9 @@ public final class AntPathRequestMatcher implements RequestMatcher, RequestVaria
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof AntPathRequestMatcher)) {
|
||||
if (!(obj instanceof AntPathRequestMatcher other)) {
|
||||
return false;
|
||||
}
|
||||
AntPathRequestMatcher other = (AntPathRequestMatcher) obj;
|
||||
return this.pattern.equals(other.pattern) && this.httpMethod == other.httpMethod
|
||||
&& this.caseSensitive == other.caseSensitive;
|
||||
}
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ public class MediaTypeRequestMatcherTests {
|
||||
|
||||
@Test
|
||||
public void constructorWhenEmptyMediaTypeThenIAE() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new MediaTypeRequestMatcher());
|
||||
assertThatIllegalArgumentException().isThrownBy(MediaTypeRequestMatcher::new);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user