From dcbc2ef134452b405b32e1b0761bfb45eb1b6078 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Thu, 7 Mar 2024 13:13:21 +0100 Subject: [PATCH] Polishing --- .../expression/AnnotatedElementKey.java | 6 ++-- .../expression/CachedExpressionEvaluator.java | 31 +++++++++---------- .../spel/SpelParserConfiguration.java | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/expression/AnnotatedElementKey.java b/spring-context/src/main/java/org/springframework/context/expression/AnnotatedElementKey.java index 194d6ca133c..08673db5e6b 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/AnnotatedElementKey.java +++ b/spring-context/src/main/java/org/springframework/context/expression/AnnotatedElementKey.java @@ -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"); * you may not use this file except in compliance with the License. @@ -23,8 +23,8 @@ import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; /** - * Represent an {@link AnnotatedElement} on a particular {@link Class} - * and is suitable as a key. + * Represents an {@link AnnotatedElement} in a particular {@link Class} + * and is suitable for use as a cache key. * * @author Costin Leau * @author Stephane Nicoll diff --git a/spring-context/src/main/java/org/springframework/context/expression/CachedExpressionEvaluator.java b/spring-context/src/main/java/org/springframework/context/expression/CachedExpressionEvaluator.java index ffd9ff96984..70683bcdf71 100644 --- a/spring-context/src/main/java/org/springframework/context/expression/CachedExpressionEvaluator.java +++ b/spring-context/src/main/java/org/springframework/context/expression/CachedExpressionEvaluator.java @@ -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"); * you may not use this file except in compliance with the License. @@ -24,11 +24,10 @@ import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.lang.Nullable; import org.springframework.util.Assert; -import org.springframework.util.ObjectUtils; /** * Shared utility class used to evaluate and cache SpEL expressions that - * are defined on {@link java.lang.reflect.AnnotatedElement}. + * are defined on an {@link java.lang.reflect.AnnotatedElement AnnotatedElement}. * * @author Stephane Nicoll * @since 4.2 @@ -42,18 +41,18 @@ public abstract class CachedExpressionEvaluator { /** - * Create a new instance with the specified {@link SpelExpressionParser}. + * Create a new instance with the default {@link SpelExpressionParser}. */ - protected CachedExpressionEvaluator(SpelExpressionParser parser) { - Assert.notNull(parser, "SpelExpressionParser must not be null"); - this.parser = parser; + protected CachedExpressionEvaluator() { + this(new SpelExpressionParser()); } /** - * Create a new instance with a default {@link SpelExpressionParser}. + * Create a new instance with the specified {@link SpelExpressionParser}. */ - protected CachedExpressionEvaluator() { - this(new SpelExpressionParser()); + protected CachedExpressionEvaluator(SpelExpressionParser parser) { + Assert.notNull(parser, "SpelExpressionParser must not be null"); + this.parser = parser; } @@ -72,12 +71,13 @@ public abstract class CachedExpressionEvaluator { return this.parameterNameDiscoverer; } - /** - * Return the {@link Expression} for the specified SpEL value - *
{@link #parseExpression(String) Parse the expression} if it hasn't been already. + * Return the parsed {@link Expression} for the specified SpEL expression. + *
{@linkplain #parseExpression(String) Parses} the expression if it hasn't
+ * already been parsed and cached.
* @param cache the cache to use
- * @param elementKey the element on which the expression is defined
+ * @param elementKey the {@code AnnotatedElementKey} containing the element
+ * on which the expression is defined
* @param expression the expression to parse
*/
protected Expression getExpression(Map