Skip to content

Commit 33fbd71

Browse files
committed
Make AstUtils package-private
AstUtils was never intended to be a public utility class.
1 parent 461d7a8 commit 33fbd71

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/ast/AstUtils.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.Collections;
2121
import java.util.List;
2222

23-
import org.springframework.expression.PropertyAccessor;
2423
import org.springframework.expression.TargetedAccessor;
2524
import org.springframework.lang.Nullable;
2625
import org.springframework.util.ObjectUtils;
@@ -32,7 +31,7 @@
3231
* @author Sam Brannen
3332
* @since 3.0.2
3433
*/
35-
public abstract class AstUtils {
34+
abstract class AstUtils {
3635

3736
/**
3837
* Determine the set of accessors that should be used to try to access an
@@ -52,7 +51,7 @@ public abstract class AstUtils {
5251
* accessor could be found
5352
* @since 6.2
5453
*/
55-
public static <T extends TargetedAccessor> List<T> getAccessorsToTry(
54+
static <T extends TargetedAccessor> List<T> getAccessorsToTry(
5655
@Nullable Class<?> targetType, List<T> accessors) {
5756

5857
if (accessors.isEmpty()) {
@@ -93,28 +92,4 @@ else if (clazz.isAssignableFrom(targetType)) {
9392
}
9493
}
9594

96-
/**
97-
* Determine the set of property accessors that should be used to try to
98-
* access a property on the specified target type.
99-
* <p>The accessors are considered to be in an ordered list; however, in the
100-
* returned list any accessors that are exact matches for the input target
101-
* type (as opposed to 'generic' accessors that could work for any type) are
102-
* placed at the start of the list. In addition, if there are specific
103-
* accessors that exactly name the class in question and accessors that name
104-
* a specific class which is a supertype of the class in question, the latter
105-
* are put at the end of the specific accessors set and will be tried after
106-
* exactly matching accessors but before generic accessors.
107-
* @param targetType the type upon which property access is being attempted
108-
* @param propertyAccessors the list of property accessors to process
109-
* @return a list of accessors that should be tried in order to access the
110-
* property on the specified target type, or an empty list if no suitable
111-
* accessor could be found
112-
* @see #getAccessorsToTry(Class, List)
113-
*/
114-
public static List<PropertyAccessor> getPropertyAccessorsToTry(
115-
@Nullable Class<?> targetType, List<PropertyAccessor> propertyAccessors) {
116-
117-
return getAccessorsToTry(targetType, propertyAccessors);
118-
}
119-
12095
}

spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,8 @@ public TypedValue getValue() {
791791
Assert.state(accessor != null, "No cached PropertyAccessor for reading");
792792
return accessor.read(this.evaluationContext, this.targetObject, this.name);
793793
}
794-
List<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry(
795-
targetType, this.evaluationContext.getPropertyAccessors());
794+
List<PropertyAccessor> accessorsToTry = AstUtils.getAccessorsToTry(targetType,
795+
this.evaluationContext.getPropertyAccessors());
796796
for (PropertyAccessor accessor : accessorsToTry) {
797797
if (accessor.canRead(this.evaluationContext, this.targetObject, this.name)) {
798798
if (accessor instanceof ReflectivePropertyAccessor reflectivePropertyAccessor) {
@@ -830,8 +830,8 @@ public void setValue(@Nullable Object newValue) {
830830
accessor.write(this.evaluationContext, this.targetObject, this.name, newValue);
831831
return;
832832
}
833-
List<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry(
834-
targetType, this.evaluationContext.getPropertyAccessors());
833+
List<PropertyAccessor> accessorsToTry = AstUtils.getAccessorsToTry(targetType,
834+
this.evaluationContext.getPropertyAccessors());
835835
for (PropertyAccessor accessor : accessorsToTry) {
836836
if (accessor.canWrite(this.evaluationContext, this.targetObject, this.name)) {
837837
updatePropertyWriteState(accessor, this.name, targetType);

spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public boolean isWritableProperty(String name, TypedValue contextObject, Evaluat
302302
/**
303303
* Determine the set of property accessors that should be used to try to
304304
* access a property on the specified context object.
305-
* <p>Delegates to {@link AstUtils#getPropertyAccessorsToTry(Class, List)}.
305+
* <p>Delegates to {@link AstUtils#getAccessorsToTry(Class, List)}.
306306
* @param targetObject the object upon which property access is being attempted
307307
* @return a list of accessors that should be tried in order to access the
308308
* property, or an empty list if no suitable accessor could be found
@@ -311,7 +311,7 @@ private List<PropertyAccessor> getPropertyAccessorsToTry(
311311
@Nullable Object targetObject, List<PropertyAccessor> propertyAccessors) {
312312

313313
Class<?> targetType = (targetObject != null ? targetObject.getClass() : null);
314-
return AstUtils.getPropertyAccessorsToTry(targetType, propertyAccessors);
314+
return AstUtils.getAccessorsToTry(targetType, propertyAccessors);
315315
}
316316

317317
@Override

0 commit comments

Comments
 (0)