From e5a6711d297730824de1a95235f848d99ac3ca6c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 2 Jul 2018 13:55:18 +0200 Subject: [PATCH] Consistent final declaration for static delegate classes Issue: SPR-16968 --- .../org/springframework/aop/framework/AopContext.java | 6 +++++- .../framework/adapter/GlobalAdvisorAdapterRegistry.java | 8 ++++++-- .../springframework/beans/PropertyAccessorFactory.java | 8 ++++++-- .../springframework/context/i18n/LocaleContextHolder.java | 8 ++++++-- .../org/springframework/core/BridgeMethodResolver.java | 6 +++++- .../java/org/springframework/core/CollectionFactory.java | 6 +++++- .../main/java/org/springframework/core/Conventions.java | 6 +++++- .../org/springframework/core/GenericTypeResolver.java | 8 ++++++-- .../java/org/springframework/core/MethodIntrospector.java | 6 +++++- .../java/org/springframework/core/SpringProperties.java | 6 +++++- .../core/convert/support/ConversionServiceFactory.java | 8 ++++++-- .../core/io/support/SpringFactoriesLoader.java | 6 +++++- 12 files changed, 65 insertions(+), 17 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java index 796d30b879..23b992a454 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopContext.java @@ -39,7 +39,7 @@ import org.springframework.lang.Nullable; * @author Juergen Hoeller * @since 13.03.2003 */ -public abstract class AopContext { +public final class AopContext { /** * ThreadLocal holder for AOP proxy associated with this thread. @@ -50,6 +50,10 @@ public abstract class AopContext { private static final ThreadLocal currentProxy = new NamedThreadLocal<>("Current AOP proxy"); + private AopContext() { + } + + /** * Try to return the current AOP proxy. This method is usable only if the * calling method has been invoked via AOP, and the AOP framework has been set diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/GlobalAdvisorAdapterRegistry.java b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/GlobalAdvisorAdapterRegistry.java index 0cd2d7ef9d..f9a677c5ad 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/adapter/GlobalAdvisorAdapterRegistry.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/adapter/GlobalAdvisorAdapterRegistry.java @@ -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. @@ -24,7 +24,11 @@ package org.springframework.aop.framework.adapter; * @author Phillip Webb * @see DefaultAdvisorAdapterRegistry */ -public abstract class GlobalAdvisorAdapterRegistry { +public final class GlobalAdvisorAdapterRegistry { + + private GlobalAdvisorAdapterRegistry() { + } + /** * Keep track of a single instance so we can return it to classes that request it. diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyAccessorFactory.java b/spring-beans/src/main/java/org/springframework/beans/PropertyAccessorFactory.java index f605806983..d33a96ea03 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyAccessorFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyAccessorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 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. @@ -24,7 +24,11 @@ package org.springframework.beans; * @author Juergen Hoeller * @since 2.5.2 */ -public abstract class PropertyAccessorFactory { +public final class PropertyAccessorFactory { + + private PropertyAccessorFactory() { + } + /** * Obtain a BeanWrapper for the given target object, diff --git a/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java b/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java index 7f8c10d0d9..2b3f43f4e1 100644 --- a/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java +++ b/spring-context/src/main/java/org/springframework/context/i18n/LocaleContextHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 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. @@ -42,7 +42,7 @@ import org.springframework.lang.Nullable; * @see org.springframework.context.support.MessageSourceAccessor * @see org.springframework.web.servlet.DispatcherServlet */ -public abstract class LocaleContextHolder { +public final class LocaleContextHolder { private static final ThreadLocal localeContextHolder = new NamedThreadLocal<>("LocaleContext"); @@ -59,6 +59,10 @@ public abstract class LocaleContextHolder { private static TimeZone defaultTimeZone; + private LocaleContextHolder() { + } + + /** * Reset the LocaleContext for the current thread. */ diff --git a/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java b/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java index 2c7318b8d6..e1c1d7b89c 100644 --- a/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java +++ b/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java @@ -45,7 +45,11 @@ import org.springframework.util.ReflectionUtils; * @author Phillip Webb * @since 2.0 */ -public abstract class BridgeMethodResolver { +public final class BridgeMethodResolver { + + private BridgeMethodResolver() { + } + /** * Find the original method for the supplied {@link Method bridge Method}. diff --git a/spring-core/src/main/java/org/springframework/core/CollectionFactory.java b/spring-core/src/main/java/org/springframework/core/CollectionFactory.java index 74e29c5e7f..05c6ac8359 100644 --- a/spring-core/src/main/java/org/springframework/core/CollectionFactory.java +++ b/spring-core/src/main/java/org/springframework/core/CollectionFactory.java @@ -53,7 +53,7 @@ import org.springframework.util.ReflectionUtils; * @author Sam Brannen * @since 1.1.1 */ -public abstract class CollectionFactory { +public final class CollectionFactory { private static final Set> approximableCollectionTypes = new HashSet<>(); @@ -85,6 +85,10 @@ public abstract class CollectionFactory { } + private CollectionFactory() { + } + + /** * Determine whether the given collection type is an approximable type, * i.e. a type that {@link #createApproximateCollection} can approximate. diff --git a/spring-core/src/main/java/org/springframework/core/Conventions.java b/spring-core/src/main/java/org/springframework/core/Conventions.java index 0d333c96d6..e6191747ec 100644 --- a/spring-core/src/main/java/org/springframework/core/Conventions.java +++ b/spring-core/src/main/java/org/springframework/core/Conventions.java @@ -34,7 +34,7 @@ import org.springframework.util.ClassUtils; * @author Rossen Stoyanchev * @since 2.0 */ -public abstract class Conventions { +public final class Conventions { /** * Suffix added to names when using arrays. @@ -42,6 +42,10 @@ public abstract class Conventions { private static final String PLURAL_SUFFIX = "List"; + private Conventions() { + } + + /** * Determine the conventional variable name for the supplied {@code Object} * based on its concrete type. The convention used is to return the diff --git a/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java b/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java index 585a5c9bf9..307bd502b4 100644 --- a/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java +++ b/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java @@ -41,13 +41,17 @@ import org.springframework.util.ConcurrentReferenceHashMap; * @author Phillip Webb * @since 2.5.2 */ -public abstract class GenericTypeResolver { +public final class GenericTypeResolver { /** Cache from Class to TypeVariable Map. */ @SuppressWarnings("rawtypes") private static final Map, Map> typeVariableCache = new ConcurrentReferenceHashMap<>(); + private GenericTypeResolver() { + } + + /** * Determine the target type for the given generic parameter type. * @param methodParameter the method parameter specification @@ -86,7 +90,7 @@ public abstract class GenericTypeResolver { */ @Nullable public static Class resolveReturnTypeArgument(Method method, Class genericIfc) { - Assert.notNull(method, "method must not be null"); + Assert.notNull(method, "Method must not be null"); ResolvableType resolvableType = ResolvableType.forMethodReturnType(method).as(genericIfc); if (!resolvableType.hasGenerics() || resolvableType.getType() instanceof WildcardType) { return null; diff --git a/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java b/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java index be7ea23a9a..dc56f5270c 100644 --- a/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java +++ b/spring-core/src/main/java/org/springframework/core/MethodIntrospector.java @@ -38,7 +38,11 @@ import org.springframework.util.ReflectionUtils; * @author Rossen Stoyanchev * @since 4.2.3 */ -public abstract class MethodIntrospector { +public final class MethodIntrospector { + + private MethodIntrospector() { + } + /** * Select methods on the given target type based on the lookup of associated metadata. diff --git a/spring-core/src/main/java/org/springframework/core/SpringProperties.java b/spring-core/src/main/java/org/springframework/core/SpringProperties.java index dedeed6ee4..eadd86fdbf 100644 --- a/spring-core/src/main/java/org/springframework/core/SpringProperties.java +++ b/spring-core/src/main/java/org/springframework/core/SpringProperties.java @@ -46,7 +46,7 @@ import org.springframework.lang.Nullable; * @see org.springframework.jdbc.core.StatementCreatorUtils#IGNORE_GETPARAMETERTYPE_PROPERTY_NAME * @see org.springframework.test.context.cache.ContextCache#MAX_CONTEXT_CACHE_SIZE_PROPERTY_NAME */ -public abstract class SpringProperties { +public final class SpringProperties { private static final String PROPERTIES_RESOURCE_LOCATION = "spring.properties"; @@ -79,6 +79,10 @@ public abstract class SpringProperties { } + private SpringProperties() { + } + + /** * Programmatically set a local property, overriding an entry in the * {@code spring.properties} file (if any). diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java b/spring-core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java index 279ff216a5..967797dd28 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 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. @@ -33,7 +33,11 @@ import org.springframework.lang.Nullable; * @author Chris Beams * @since 3.0 */ -public abstract class ConversionServiceFactory { +public final class ConversionServiceFactory { + + private ConversionServiceFactory() { + } + /** * Register the given Converter objects with the given target ConverterRegistry. diff --git a/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java b/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java index a22747e578..c53e162ee9 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java @@ -60,7 +60,7 @@ import org.springframework.util.StringUtils; * @author Sam Brannen * @since 3.2 */ -public abstract class SpringFactoriesLoader { +public final class SpringFactoriesLoader { /** * The location to look for factories. @@ -74,6 +74,10 @@ public abstract class SpringFactoriesLoader { private static final Map> cache = new ConcurrentReferenceHashMap<>(); + private SpringFactoriesLoader() { + } + + /** * Load and instantiate the factory implementations of the given type from * {@value #FACTORIES_RESOURCE_LOCATION}, using the given class loader.