Make classes final where possible

Update classes that have private constructors so that they are also
declared final. In a few cases, inner-classes used private constructors
but were subclassed. These have now been changed to have package-private
constructors.

Issue gh-8945
This commit is contained in:
Phillip Webb
2020-07-24 19:03:31 -07:00
committed by Rob Winch
parent b5d499e2eb
commit 6894ff5d12
58 changed files with 229 additions and 226 deletions

View File

@@ -294,7 +294,7 @@ public class FilterChainProxy extends GenericFilterBean {
* Internal {@code FilterChain} implementation that is used to pass a request through
* the additional internal list of filters which match the request.
*/
private static class VirtualFilterChain implements FilterChain {
private static final class VirtualFilterChain implements FilterChain {
private final FilterChain originalChain;

View File

@@ -35,7 +35,7 @@ import org.springframework.web.server.ServerWebExchange;
* @author Mathieu Ouellet
* @since 5.0
*/
public class DelegatingReactiveAuthorizationManager implements ReactiveAuthorizationManager<ServerWebExchange> {
public final class DelegatingReactiveAuthorizationManager implements ReactiveAuthorizationManager<ServerWebExchange> {
private static final Log logger = LogFactory.getLog(DelegatingReactiveAuthorizationManager.class);
@@ -63,7 +63,7 @@ public class DelegatingReactiveAuthorizationManager implements ReactiveAuthoriza
return new DelegatingReactiveAuthorizationManager.Builder();
}
public static class Builder {
public static final class Builder {
private final List<ServerWebExchangeMatcherEntry<ReactiveAuthorizationManager<AuthorizationContext>>> mappings = new ArrayList<>();

View File

@@ -28,13 +28,15 @@ import org.springframework.web.server.ServerWebExchange;
* @author Rob Winch
* @since 5.0
*/
public class NoOpServerSecurityContextRepository implements ServerSecurityContextRepository {
public final class NoOpServerSecurityContextRepository implements ServerSecurityContextRepository {
private static final NoOpServerSecurityContextRepository INSTANCE = new NoOpServerSecurityContextRepository();
private NoOpServerSecurityContextRepository() {
}
public Mono<Void> save(ServerWebExchange exchange, SecurityContext context) {
return Mono.empty();
}
public Mono<SecurityContext> load(ServerWebExchange exchange) {
@@ -45,7 +47,4 @@ public class NoOpServerSecurityContextRepository implements ServerSecurityContex
return INSTANCE;
}
private NoOpServerSecurityContextRepository() {
}
}

View File

@@ -30,7 +30,10 @@ import org.springframework.web.server.ServerWebExchange;
* @author Rob Winch
* @since 5.0
*/
public class NoOpServerRequestCache implements ServerRequestCache {
public final class NoOpServerRequestCache implements ServerRequestCache {
private NoOpServerRequestCache() {
}
@Override
public Mono<Void> saveRequest(ServerWebExchange exchange) {
@@ -51,7 +54,4 @@ public class NoOpServerRequestCache implements ServerRequestCache {
return new NoOpServerRequestCache();
}
private NoOpServerRequestCache() {
}
}

View File

@@ -263,7 +263,7 @@ public final class AntPathRequestMatcher implements RequestMatcher, RequestVaria
}
private static class SpringAntMatcher implements Matcher {
private static final class SpringAntMatcher implements Matcher {
private final AntPathMatcher antMatcher;
@@ -296,7 +296,7 @@ public final class AntPathRequestMatcher implements RequestMatcher, RequestVaria
/**
* Optimized matcher for trailing wildcards
*/
private static class SubpathMatcher implements Matcher {
private static final class SubpathMatcher implements Matcher {
private final String subpath;