Fix wording in SpEL's PropertyAccessor Javadoc

The documentation now properly refers to "property accessors" instead
of "resolvers".
This commit is contained in:
Sam Brannen 2024-03-25 14:26:40 +01:00
parent 7c009ccc1f
commit 57632f9f08
2 changed files with 32 additions and 27 deletions

View File

@ -34,7 +34,7 @@ package org.springframework.expression;
* @author Andy Clement * @author Andy Clement
* @author Sam Brannen * @author Sam Brannen
* @since 3.0 * @since 3.0
* @see ConstructorResolver * @see MethodResolver
* @see MethodExecutor * @see MethodExecutor
*/ */
@FunctionalInterface @FunctionalInterface

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,20 +19,23 @@ package org.springframework.expression;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
* A property accessor is able to read from (and possibly write to) an object's properties. * A property accessor is able to read from (and possibly write to) an object's
* properties.
* *
* <p>This interface places no restrictions, and so implementors are free to access properties * <p>This interface places no restrictions on what constitutes a property.
* directly as fields or through getters or in any other way they see as appropriate. * Implementors are therefore free to access properties directly via fields,
* through getters, or in any other way they deem appropriate.
* *
* <p>A resolver can optionally specify an array of target classes for which it should be * <p>A property accessor can optionally specify an array of target classes for
* called. However, if it returns {@code null} from {@link #getSpecificTargetClasses()}, * which it should be called. However, if it returns {@code null} from
* it will be called for all property references and given a chance to determine if it * {@link #getSpecificTargetClasses()}, it will be called for all property
* can read or write them. * references and given a chance to determine if it can read or write them.
* *
* <p>Property resolvers are considered to be ordered, and each will be called in turn. * <p>Property accessors are considered to be ordered, and each will be called in
* The only rule that affects the call order is that any resolver naming the target * turn. The only rule that affects the call order is that any property accessor
* class directly in {@link #getSpecificTargetClasses()} will be called first, before * which specifies explicit support for the target class via
* the general resolvers. * {@link #getSpecificTargetClasses()} will be called first, before the general
* property accessors.
* *
* @author Andy Clement * @author Andy Clement
* @since 3.0 * @since 3.0
@ -40,44 +43,46 @@ import org.springframework.lang.Nullable;
public interface PropertyAccessor { public interface PropertyAccessor {
/** /**
* Return an array of classes for which this resolver should be called. * Return an array of classes for which this property accessor should be called.
* <p>Returning {@code null} indicates this is a general resolver that * <p>Returning {@code null} indicates this is a general property accessor that
* can be called in an attempt to resolve a property on any type. * can be called in an attempt to resolve a property on any type.
* @return an array of classes that this resolver is suitable for * @return an array of classes that this property accessor is suitable for
* (or {@code null} if a general resolver) * (or {@code null} if a general property accessor)
*/ */
@Nullable @Nullable
Class<?>[] getSpecificTargetClasses(); Class<?>[] getSpecificTargetClasses();
/** /**
* Called to determine if a resolver instance is able to access a specified property * Called to determine if this property accessor is able to read a specified
* on a specified target object. * property on a specified target object.
* @param context the evaluation context in which the access is being attempted * @param context the evaluation context in which the access is being attempted
* @param target the target object upon which the property is being accessed * @param target the target object upon which the property is being accessed
* @param name the name of the property being accessed * @param name the name of the property being accessed
* @return true if this resolver is able to read the property * @return true if this property accessor is able to read the property
* @throws AccessException if there is any problem determining whether the property can be read * @throws AccessException if there is any problem determining whether the
* property can be read
*/ */
boolean canRead(EvaluationContext context, @Nullable Object target, String name) throws AccessException; boolean canRead(EvaluationContext context, @Nullable Object target, String name) throws AccessException;
/** /**
* Called to read a property from a specified target object. * Called to read a property from a specified target object.
* Should only succeed if {@link #canRead} also returns {@code true}. * <p>Should only succeed if {@link #canRead} also returns {@code true}.
* @param context the evaluation context in which the access is being attempted * @param context the evaluation context in which the access is being attempted
* @param target the target object upon which the property is being accessed * @param target the target object upon which the property is being accessed
* @param name the name of the property being accessed * @param name the name of the property being accessed
* @return a TypedValue object wrapping the property value read and a type descriptor for it * @return a TypedValue object wrapping the property value read and a type
* @throws AccessException if there is any problem accessing the property value * descriptor for it
* @throws AccessException if there is any problem reading the property value
*/ */
TypedValue read(EvaluationContext context, @Nullable Object target, String name) throws AccessException; TypedValue read(EvaluationContext context, @Nullable Object target, String name) throws AccessException;
/** /**
* Called to determine if a resolver instance is able to write to a specified * Called to determine if this property accessor is able to write to a specified
* property on a specified target object. * property on a specified target object.
* @param context the evaluation context in which the access is being attempted * @param context the evaluation context in which the access is being attempted
* @param target the target object upon which the property is being accessed * @param target the target object upon which the property is being accessed
* @param name the name of the property being accessed * @param name the name of the property being accessed
* @return true if this resolver is able to write to the property * @return true if this property accessor is able to write to the property
* @throws AccessException if there is any problem determining whether the * @throws AccessException if there is any problem determining whether the
* property can be written to * property can be written to
*/ */
@ -85,7 +90,7 @@ public interface PropertyAccessor {
/** /**
* Called to write to a property on a specified target object. * Called to write to a property on a specified target object.
* Should only succeed if {@link #canWrite} also returns {@code true}. * <p>Should only succeed if {@link #canWrite} also returns {@code true}.
* @param context the evaluation context in which the access is being attempted * @param context the evaluation context in which the access is being attempted
* @param target the target object upon which the property is being accessed * @param target the target object upon which the property is being accessed
* @param name the name of the property being accessed * @param name the name of the property being accessed