From 33fbd7141d46c281cdc0a26d4bdeb21b00bdb5d3 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:41:45 +0300 Subject: [PATCH] Make AstUtils package-private AstUtils was never intended to be a public utility class. --- .../expression/spel/ast/AstUtils.java | 29 ++----------------- .../expression/spel/ast/Indexer.java | 8 ++--- .../spel/ast/PropertyOrFieldReference.java | 4 +-- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java index 665f1b6ee1..63e568a10b 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.springframework.expression.PropertyAccessor; import org.springframework.expression.TargetedAccessor; import org.springframework.lang.Nullable; import org.springframework.util.ObjectUtils; @@ -32,7 +31,7 @@ import org.springframework.util.ObjectUtils; * @author Sam Brannen * @since 3.0.2 */ -public abstract class AstUtils { +abstract class AstUtils { /** * Determine the set of accessors that should be used to try to access an @@ -52,7 +51,7 @@ public abstract class AstUtils { * accessor could be found * @since 6.2 */ - public static List getAccessorsToTry( + static List getAccessorsToTry( @Nullable Class targetType, List accessors) { if (accessors.isEmpty()) { @@ -93,28 +92,4 @@ public abstract class AstUtils { } } - /** - * Determine the set of property accessors that should be used to try to - * access a property on the specified target type. - *

The accessors are considered to be in an ordered list; however, in the - * returned list any accessors that are exact matches for the input target - * type (as opposed to 'generic' accessors that could work for any type) are - * placed at the start of the list. In addition, if there are specific - * accessors that exactly name the class in question and accessors that name - * a specific class which is a supertype of the class in question, the latter - * are put at the end of the specific accessors set and will be tried after - * exactly matching accessors but before generic accessors. - * @param targetType the type upon which property access is being attempted - * @param propertyAccessors the list of property accessors to process - * @return a list of accessors that should be tried in order to access the - * property on the specified target type, or an empty list if no suitable - * accessor could be found - * @see #getAccessorsToTry(Class, List) - */ - public static List getPropertyAccessorsToTry( - @Nullable Class targetType, List propertyAccessors) { - - return getAccessorsToTry(targetType, propertyAccessors); - } - } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java index f3ba081fda..0809c02d75 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java @@ -791,8 +791,8 @@ public class Indexer extends SpelNodeImpl { Assert.state(accessor != null, "No cached PropertyAccessor for reading"); return accessor.read(this.evaluationContext, this.targetObject, this.name); } - List accessorsToTry = AstUtils.getPropertyAccessorsToTry( - targetType, this.evaluationContext.getPropertyAccessors()); + List accessorsToTry = AstUtils.getAccessorsToTry(targetType, + this.evaluationContext.getPropertyAccessors()); for (PropertyAccessor accessor : accessorsToTry) { if (accessor.canRead(this.evaluationContext, this.targetObject, this.name)) { if (accessor instanceof ReflectivePropertyAccessor reflectivePropertyAccessor) { @@ -830,8 +830,8 @@ public class Indexer extends SpelNodeImpl { accessor.write(this.evaluationContext, this.targetObject, this.name, newValue); return; } - List accessorsToTry = AstUtils.getPropertyAccessorsToTry( - targetType, this.evaluationContext.getPropertyAccessors()); + List accessorsToTry = AstUtils.getAccessorsToTry(targetType, + this.evaluationContext.getPropertyAccessors()); for (PropertyAccessor accessor : accessorsToTry) { if (accessor.canWrite(this.evaluationContext, this.targetObject, this.name)) { updatePropertyWriteState(accessor, this.name, targetType); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java index 751b9cb30c..2aab75f9c6 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java @@ -302,7 +302,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl { /** * Determine the set of property accessors that should be used to try to * access a property on the specified context object. - *

Delegates to {@link AstUtils#getPropertyAccessorsToTry(Class, List)}. + *

Delegates to {@link AstUtils#getAccessorsToTry(Class, List)}. * @param targetObject the object upon which property access is being attempted * @return a list of accessors that should be tried in order to access the * property, or an empty list if no suitable accessor could be found @@ -311,7 +311,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl { @Nullable Object targetObject, List propertyAccessors) { Class targetType = (targetObject != null ? targetObject.getClass() : null); - return AstUtils.getPropertyAccessorsToTry(targetType, propertyAccessors); + return AstUtils.getAccessorsToTry(targetType, propertyAccessors); } @Override