Use consistent class design

Update all classes so that inner classes are always last. Also
ensure that utility classes are always final and have a private
constructor and make exceptions final whenever possible.

Issue: SPR-16968
This commit is contained in:
Phillip Webb
2018-06-20 19:44:39 -07:00
committed by Juergen Hoeller
parent 0ad0f341bd
commit eeebd51f57
128 changed files with 656 additions and 455 deletions

View File

@@ -28,7 +28,7 @@ import org.springframework.util.Assert;
* @author Rossen Stoyanchev
* @since 5.0
*/
public class ReactiveTypeDescriptor {
public final class ReactiveTypeDescriptor {
private final Class<?> reactiveType;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2018 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.
@@ -31,7 +31,12 @@ import org.springframework.lang.Nullable;
* @author Juergen Hoeller
* @since 1.1
*/
public class SpringVersion {
public final class SpringVersion {
private SpringVersion() {
}
/**
* Return the full version string of the present Spring codebase,

View File

@@ -2047,7 +2047,7 @@ public abstract class AnnotationUtils {
* @see #getAttributeAliasNames
* @see #getAttributeOverrideName
*/
private static class AliasDescriptor {
private static final class AliasDescriptor {
private final Method sourceAttribute;

View File

@@ -42,7 +42,7 @@ import org.springframework.util.MimeTypeUtils;
* @since 5.0
* @see StringDecoder
*/
public class CharSequenceEncoder extends AbstractEncoder<CharSequence> {
public final class CharSequenceEncoder extends AbstractEncoder<CharSequence> {
/**
* The default charset used by the encoder.

View File

@@ -53,7 +53,7 @@ import org.springframework.util.MimeTypeUtils;
* @since 5.0
* @see CharSequenceEncoder
*/
public class StringDecoder extends AbstractDataBufferDecoder<String> {
public final class StringDecoder extends AbstractDataBufferDecoder<String> {
private static final DataBuffer END_FRAME = new DefaultDataBufferFactory().wrap(new byte[0]);

View File

@@ -31,7 +31,10 @@ import org.springframework.util.StringUtils;
* @author Phillip Webb
* @since 5.1
*/
class ProfilesParser {
final class ProfilesParser {
private ProfilesParser() {
}
static Profiles parse(String... expressions) {
Assert.notEmpty(expressions, "Must specify at least one profile");

View File

@@ -57,6 +57,27 @@ public abstract class ReflectionUtils {
private static final Field[] NO_FIELDS = {};
/**
* Pre-built FieldFilter that matches all non-static, non-final fields.
*/
public static final FieldFilter COPYABLE_FIELDS =
field -> !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers()));
/**
* Pre-built MethodFilter that matches all non-bridge methods.
*/
public static final MethodFilter NON_BRIDGED_METHODS =
(method -> !method.isBridge());
/**
* Pre-built MethodFilter that matches all non-bridge non-synthetic methods
* which are not declared on {@code java.lang.Object}.
*/
public static final MethodFilter USER_DECLARED_METHODS =
(method -> (!method.isBridge() && !method.isSynthetic() && method.getDeclaringClass() != Object.class));
/**
* Cache for {@link Class#getDeclaredMethods()} plus equivalent default methods
@@ -847,25 +868,4 @@ public abstract class ReflectionUtils {
}
/**
* Pre-built FieldFilter that matches all non-static, non-final fields.
*/
public static final FieldFilter COPYABLE_FIELDS =
field -> !(Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers()));
/**
* Pre-built MethodFilter that matches all non-bridge methods.
*/
public static final MethodFilter NON_BRIDGED_METHODS =
(method -> !method.isBridge());
/**
* Pre-built MethodFilter that matches all non-bridge non-synthetic methods
* which are not declared on {@code java.lang.Object}.
*/
public static final MethodFilter USER_DECLARED_METHODS =
(method -> (!method.isBridge() && !method.isSynthetic() && method.getDeclaringClass() != Object.class));
}