Make AstUtils package-private
AstUtils was never intended to be a public utility class.
This commit is contained in:
parent
461d7a82f6
commit
33fbd7141d
|
@ -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 <T extends TargetedAccessor> List<T> getAccessorsToTry(
|
||||
static <T extends TargetedAccessor> List<T> getAccessorsToTry(
|
||||
@Nullable Class<?> targetType, List<T> 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.
|
||||
* <p>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<PropertyAccessor> getPropertyAccessorsToTry(
|
||||
@Nullable Class<?> targetType, List<PropertyAccessor> propertyAccessors) {
|
||||
|
||||
return getAccessorsToTry(targetType, propertyAccessors);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry(
|
||||
targetType, this.evaluationContext.getPropertyAccessors());
|
||||
List<PropertyAccessor> 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<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry(
|
||||
targetType, this.evaluationContext.getPropertyAccessors());
|
||||
List<PropertyAccessor> 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);
|
||||
|
|
|
@ -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.
|
||||
* <p>Delegates to {@link AstUtils#getPropertyAccessorsToTry(Class, List)}.
|
||||
* <p>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<PropertyAccessor> propertyAccessors) {
|
||||
|
||||
Class<?> targetType = (targetObject != null ? targetObject.getClass() : null);
|
||||
return AstUtils.getPropertyAccessorsToTry(targetType, propertyAccessors);
|
||||
return AstUtils.getAccessorsToTry(targetType, propertyAccessors);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue