Polish diamond operator usage

This commit is contained in:
Tran Ngoc Nhan 2024-10-11 21:44:08 +07:00 committed by Josh Cummings
parent f3e95c8175
commit 31f8caec5f
24 changed files with 42 additions and 44 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -95,7 +95,7 @@ class InitializeAuthenticationProviderBeanManagerConfigurer extends GlobalAuthen
.getBeanNamesForType(type); .getBeanNamesForType(type);
for (String beanName : beanNames) { for (String beanName : beanNames) {
T bean = InitializeAuthenticationProviderBeanManagerConfigurer.this.context.getBean(beanName, type); T bean = InitializeAuthenticationProviderBeanManagerConfigurer.this.context.getBean(beanName, type);
beanWithNames.add(new BeanWithName<T>(bean, beanName)); beanWithNames.add(new BeanWithName<>(bean, beanName));
} }
return beanWithNames; return beanWithNames;
} }

View File

@ -134,7 +134,7 @@ class InitializeUserDetailsBeanManagerConfigurer extends GlobalAuthenticationCon
String[] beanNames = InitializeUserDetailsBeanManagerConfigurer.this.context.getBeanNamesForType(type); String[] beanNames = InitializeUserDetailsBeanManagerConfigurer.this.context.getBeanNamesForType(type);
for (String beanName : beanNames) { for (String beanName : beanNames) {
T bean = InitializeUserDetailsBeanManagerConfigurer.this.context.getBean(beanName, type); T bean = InitializeUserDetailsBeanManagerConfigurer.this.context.getBean(beanName, type);
beanWithNames.add(new BeanWithName<T>(bean, beanName)); beanWithNames.add(new BeanWithName<>(bean, beanName));
} }
return beanWithNames; return beanWithNames;
} }

View File

@ -97,7 +97,7 @@ public class GlobalMethodSecurityConfiguration implements ImportAware, SmartInit
private static final Log logger = LogFactory.getLog(GlobalMethodSecurityConfiguration.class); private static final Log logger = LogFactory.getLog(GlobalMethodSecurityConfiguration.class);
private ObjectPostProcessor<Object> objectPostProcessor = new ObjectPostProcessor<Object>() { private ObjectPostProcessor<Object> objectPostProcessor = new ObjectPostProcessor<>() {
@Override @Override
public <T> T postProcess(T object) { public <T> T postProcess(T object) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2015-2018 the original author or authors. * Copyright 2015-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -42,7 +42,7 @@ import org.springframework.security.core.userdetails.User;
*/ */
class UserDeserializer extends JsonDeserializer<User> { class UserDeserializer extends JsonDeserializer<User> {
private static final TypeReference<Set<SimpleGrantedAuthority>> SIMPLE_GRANTED_AUTHORITY_SET = new TypeReference<Set<SimpleGrantedAuthority>>() { private static final TypeReference<Set<SimpleGrantedAuthority>> SIMPLE_GRANTED_AUTHORITY_SET = new TypeReference<>() {
}; };
/** /**

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2015-2022 the original author or authors. * Copyright 2015-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -50,10 +50,10 @@ import org.springframework.security.core.GrantedAuthority;
*/ */
class UsernamePasswordAuthenticationTokenDeserializer extends JsonDeserializer<UsernamePasswordAuthenticationToken> { class UsernamePasswordAuthenticationTokenDeserializer extends JsonDeserializer<UsernamePasswordAuthenticationToken> {
private static final TypeReference<List<GrantedAuthority>> GRANTED_AUTHORITY_LIST = new TypeReference<List<GrantedAuthority>>() { private static final TypeReference<List<GrantedAuthority>> GRANTED_AUTHORITY_LIST = new TypeReference<>() {
}; };
private static final TypeReference<Object> OBJECT = new TypeReference<Object>() { private static final TypeReference<Object> OBJECT = new TypeReference<>() {
}; };
/** /**

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,7 +29,7 @@ public interface MessageMatcher<T> {
/** /**
* Matches every {@link Message} * Matches every {@link Message}
*/ */
MessageMatcher<Object> ANY_MESSAGE = new MessageMatcher<Object>() { MessageMatcher<Object> ANY_MESSAGE = new MessageMatcher<>() {
@Override @Override
public boolean matches(Message<?> message) { public boolean matches(Message<?> message) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,7 +31,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
*/ */
abstract class JsonNodeUtils { abstract class JsonNodeUtils {
static final TypeReference<Set<String>> STRING_SET = new TypeReference<Set<String>>() { static final TypeReference<Set<String>> STRING_SET = new TypeReference<>() {
}; };
static final TypeReference<Map<String, Object>> STRING_OBJECT_MAP = new TypeReference<Map<String, Object>>() { static final TypeReference<Map<String, Object>> STRING_OBJECT_MAP = new TypeReference<Map<String, Object>>() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -70,7 +70,7 @@ public final class ReactiveOidcIdTokenDecoderFactory implements ReactiveJwtDecod
private static final Map<JwsAlgorithm, String> JCA_ALGORITHM_MAPPINGS; private static final Map<JwsAlgorithm, String> JCA_ALGORITHM_MAPPINGS;
static { static {
Map<JwsAlgorithm, String> mappings = new HashMap<JwsAlgorithm, String>(); Map<JwsAlgorithm, String> mappings = new HashMap<>();
mappings.put(MacAlgorithm.HS256, "HmacSHA256"); mappings.put(MacAlgorithm.HS256, "HmacSHA256");
mappings.put(MacAlgorithm.HS384, "HmacSHA384"); mappings.put(MacAlgorithm.HS384, "HmacSHA384");
mappings.put(MacAlgorithm.HS512, "HmacSHA512"); mappings.put(MacAlgorithm.HS512, "HmacSHA512");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -66,7 +66,7 @@ public final class ClientRegistrations {
rest.setRequestFactory(requestFactory); rest.setRequestFactory(requestFactory);
} }
private static final ParameterizedTypeReference<Map<String, Object>> typeReference = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> typeReference = new ParameterizedTypeReference<>() {
}; };
private ClientRegistrations() { private ClientRegistrations() {

View File

@ -71,7 +71,7 @@ public class DefaultOAuth2UserService implements OAuth2UserService<OAuth2UserReq
private static final String INVALID_USER_INFO_RESPONSE_ERROR_CODE = "invalid_user_info_response"; private static final String INVALID_USER_INFO_RESPONSE_ERROR_CODE = "invalid_user_info_response";
private static final ParameterizedTypeReference<Map<String, Object>> PARAMETERIZED_RESPONSE_TYPE = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> PARAMETERIZED_RESPONSE_TYPE = new ParameterizedTypeReference<>() {
}; };
private Converter<OAuth2UserRequest, RequestEntity<?>> requestEntityConverter = new OAuth2UserRequestEntityConverter(); private Converter<OAuth2UserRequest, RequestEntity<?>> requestEntityConverter = new OAuth2UserRequestEntityConverter();

View File

@ -73,10 +73,10 @@ public class DefaultReactiveOAuth2UserService implements ReactiveOAuth2UserServi
private static final String MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE = "missing_user_name_attribute"; private static final String MISSING_USER_NAME_ATTRIBUTE_ERROR_CODE = "missing_user_name_attribute";
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() {
}; };
private static final ParameterizedTypeReference<Map<String, String>> STRING_STRING_MAP = new ParameterizedTypeReference<Map<String, String>>() { private static final ParameterizedTypeReference<Map<String, String>> STRING_STRING_MAP = new ParameterizedTypeReference<>() {
}; };
private Converter<OAuth2UserRequest, Converter<Map<String, Object>, Map<String, Object>>> attributesConverter = ( private Converter<OAuth2UserRequest, Converter<Map<String, Object>, Map<String, Object>>> attributesConverter = (

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -49,7 +49,7 @@ public class OAuth2AccessTokenResponseHttpMessageConverter
private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() {
}; };
private GenericHttpMessageConverter<Object> jsonMessageConverter = HttpMessageConverters.getJsonMessageConverter(); private GenericHttpMessageConverter<Object> jsonMessageConverter = HttpMessageConverters.getJsonMessageConverter();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -49,7 +49,7 @@ public class OAuth2ErrorHttpMessageConverter extends AbstractHttpMessageConverte
private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() {
}; };
private GenericHttpMessageConverter<Object> jsonMessageConverter = HttpMessageConverters.getJsonMessageConverter(); private GenericHttpMessageConverter<Object> jsonMessageConverter = HttpMessageConverters.getJsonMessageConverter();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -53,7 +53,7 @@ class OAuth2AccessTokenResponseBodyExtractor
private static final String INVALID_TOKEN_RESPONSE_ERROR_CODE = "invalid_token_response"; private static final String INVALID_TOKEN_RESPONSE_ERROR_CODE = "invalid_token_response";
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() {
}; };
OAuth2AccessTokenResponseBodyExtractor() { OAuth2AccessTokenResponseBodyExtractor() {

View File

@ -75,7 +75,7 @@ final class JwtDecoderProviderConfigurationUtils {
rest.setRequestFactory(requestFactory); rest.setRequestFactory(requestFactory);
} }
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() {
}; };
private JwtDecoderProviderConfigurationUtils() { private JwtDecoderProviderConfigurationUtils() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2023 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -49,7 +49,7 @@ final class ReactiveJwtDecoderProviderConfigurationUtils {
private static final String OAUTH_METADATA_PATH = "/.well-known/oauth-authorization-server"; private static final String OAUTH_METADATA_PATH = "/.well-known/oauth-authorization-server";
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() {
}; };
static <C extends SecurityContext> Mono<ConfigurableJWTProcessor<C>> addJWSAlgorithms( static <C extends SecurityContext> Mono<ConfigurableJWTProcessor<C>> addJWSAlgorithms(

View File

@ -62,7 +62,7 @@ public class SpringOpaqueTokenIntrospector implements OpaqueTokenIntrospector {
private static final String AUTHORITY_PREFIX = "SCOPE_"; private static final String AUTHORITY_PREFIX = "SCOPE_";
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() {
}; };
private final Log logger = LogFactory.getLog(getClass()); private final Log logger = LogFactory.getLog(getClass());

View File

@ -58,7 +58,7 @@ public class SpringReactiveOpaqueTokenIntrospector implements ReactiveOpaqueToke
private static final String AUTHORITY_PREFIX = "SCOPE_"; private static final String AUTHORITY_PREFIX = "SCOPE_";
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() {
}; };
private final URI introspectionUri; private final URI introspectionUri;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2019 the original author or authors. * Copyright 2019-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -81,8 +81,7 @@ public interface PayloadExchangeMatcher {
* @return * @return
*/ */
public static Mono<MatchResult> match(Map<String, ? extends Object> variables) { public static Mono<MatchResult> match(Map<String, ? extends Object> variables) {
MatchResult result = new MatchResult(true, MatchResult result = new MatchResult(true, (variables != null) ? new HashMap<>(variables) : null);
(variables != null) ? new HashMap<String, Object>(variables) : null);
return Mono.just(result); return Mono.just(result);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited * Copyright 2004-2024 Acegi Technology Pty Limited
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -138,7 +138,6 @@ public class LoginUrlAuthenticationEntryPoint implements AuthenticationEntryPoin
logger.debug(LogMessage.format("Server side forward to: %s", loginForm)); logger.debug(LogMessage.format("Server side forward to: %s", loginForm));
RequestDispatcher dispatcher = request.getRequestDispatcher(loginForm); RequestDispatcher dispatcher = request.getRequestDispatcher(loginForm);
dispatcher.forward(request, response); dispatcher.forward(request, response);
return;
} }
protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response, protected String buildRedirectUrlToLoginPage(HttpServletRequest request, HttpServletResponse response,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -129,7 +129,7 @@ final class DefaultWASUsernameAndGroupsExtractor implements WASUsernameAndGroups
final Collection<String> groups = (Collection<String>) invokeMethod(getGroupsForUserMethod(), userReg, final Collection<String> groups = (Collection<String>) invokeMethod(getGroupsForUserMethod(), userReg,
new Object[] { securityName }); new Object[] { securityName });
logger.debug(LogMessage.format("Groups for user %s: %s", securityName, groups)); logger.debug(LogMessage.format("Groups for user %s: %s", securityName, groups));
return new ArrayList<String>(groups); return new ArrayList<>(groups);
} }
catch (Exception ex) { catch (Exception ex) {
logger.error("Exception occured while looking up groups for user", ex); logger.error("Exception occured while looking up groups for user", ex);

View File

@ -737,7 +737,7 @@ public class StrictHttpFirewall implements HttpFirewall {
validateAllowedHeaderName(name); validateAllowedHeaderName(name);
} }
Enumeration<String> headers = super.getHeaders(name); Enumeration<String> headers = super.getHeaders(name);
return new Enumeration<String>() { return new Enumeration<>() {
@Override @Override
public boolean hasMoreElements() { public boolean hasMoreElements() {
@ -757,7 +757,7 @@ public class StrictHttpFirewall implements HttpFirewall {
@Override @Override
public Enumeration<String> getHeaderNames() { public Enumeration<String> getHeaderNames() {
Enumeration<String> names = super.getHeaderNames(); Enumeration<String> names = super.getHeaderNames();
return new Enumeration<String>() { return new Enumeration<>() {
@Override @Override
public boolean hasMoreElements() { public boolean hasMoreElements() {
@ -803,7 +803,7 @@ public class StrictHttpFirewall implements HttpFirewall {
@Override @Override
public Enumeration<String> getParameterNames() { public Enumeration<String> getParameterNames() {
Enumeration<String> paramaterNames = super.getParameterNames(); Enumeration<String> paramaterNames = super.getParameterNames();
return new Enumeration<String>() { return new Enumeration<>() {
@Override @Override
public boolean hasMoreElements() { public boolean hasMoreElements() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2015-2018 the original author or authors. * Copyright 2015-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ import org.springframework.security.web.authentication.preauth.PreAuthenticatedA
*/ */
class PreAuthenticatedAuthenticationTokenDeserializer extends JsonDeserializer<PreAuthenticatedAuthenticationToken> { class PreAuthenticatedAuthenticationTokenDeserializer extends JsonDeserializer<PreAuthenticatedAuthenticationToken> {
private static final TypeReference<List<GrantedAuthority>> GRANTED_AUTHORITY_LIST = new TypeReference<List<GrantedAuthority>>() { private static final TypeReference<List<GrantedAuthority>> GRANTED_AUTHORITY_LIST = new TypeReference<>() {
}; };
/** /**