Skip to content

Commit fb2afa6

Browse files
committed
Revise Javadoc for PropertyAccessor & IndexAccessor regarding ordering
Closes gh-33862
1 parent b60cc54 commit fb2afa6

File tree

4 files changed

+23
-31
lines changed

4 files changed

+23
-31
lines changed

spring-expression/src/main/java/org/springframework/expression/IndexAccessor.java

+4-11
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,14 @@
2626
* structure. Implementors are therefore free to access indexed values any way
2727
* they deem appropriate.
2828
*
29-
* <p>An index accessor can optionally specify an array of target classes for
30-
* which it should be called. However, if it returns {@code null} or an empty
31-
* array from {@link #getSpecificTargetClasses()}, it will be called for all
32-
* indexing operations and given a chance to determine if it can read from or
33-
* write to the indexed structure.
34-
*
35-
* <p>Index accessors are considered to be ordered, and each will be called in
36-
* turn. The only rule that affects the call order is that any index accessor
37-
* which specifies explicit support for the target class via
38-
* {@link #getSpecificTargetClasses()} will be called first, before other
39-
* generic index accessors.
29+
* <p>An index accessor can specify an array of
30+
* {@linkplain #getSpecificTargetClasses() target classes} for which it should be
31+
* called. See {@link TargetedAccessor} for details.
4032
*
4133
* @author Jackmiking Lee
4234
* @author Sam Brannen
4335
* @since 6.2
36+
* @see TargetedAccessor
4437
* @see PropertyAccessor
4538
*/
4639
public interface IndexAccessor extends TargetedAccessor {

spring-expression/src/main/java/org/springframework/expression/PropertyAccessor.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,13 @@
2626
* Implementors are therefore free to access properties directly via fields,
2727
* through getters, or in any other way they deem appropriate.
2828
*
29-
* <p>A property accessor can optionally specify an array of target classes for
30-
* which it should be called. However, if it returns {@code null} from
31-
* {@link #getSpecificTargetClasses()}, it will be called for all property
32-
* references and given a chance to determine if it can read or write them.
33-
*
34-
* <p>Property accessors are considered to be ordered, and each will be called in
35-
* turn. The only rule that affects the call order is that any property accessor
36-
* which specifies explicit support for the target class via
37-
* {@link #getSpecificTargetClasses()} will be called first, before the generic
38-
* property accessors.
29+
* <p>A property accessor can specify an array of
30+
* {@linkplain #getSpecificTargetClasses() target classes} for which it should be
31+
* called. See {@link TargetedAccessor} for details.
3932
*
4033
* @author Andy Clement
4134
* @since 3.0
35+
* @see TargetedAccessor
4236
* @see IndexAccessor
4337
*/
4438
public interface PropertyAccessor extends TargetedAccessor {

spring-expression/src/main/java/org/springframework/expression/TargetedAccessor.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
*
3232
* <p>Targeted accessors are considered to be ordered, and each will be called
3333
* in turn. The only rule that affects the call order is that any accessor which
34-
* specifies explicit support for a given target class via
34+
* specifies explicit support for a given target type via
3535
* {@link #getSpecificTargetClasses()} will be called first, before other generic
36-
* accessors that do not specify explicit support for the given target class.
36+
* accessors that do not specify support for explicit target types. In addition,
37+
* accessors that support the exact target type will be called before accessors
38+
* that support a supertype of the target type.
3739
*
3840
* @author Sam Brannen
3941
* @since 6.2

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

+11-8
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,23 @@ static <T extends TargetedAccessor> List<T> getAccessorsToTry(
5555
/**
5656
* Determine the set of accessors that should be used to try to access an
5757
* element on the specified target type.
58-
* <p>The accessors are considered to be in an ordered list; however, in the
59-
* returned list any accessors that are exact matches for the input target
60-
* type (as opposed to 'generic' accessors that could work for any type) are
61-
* placed at the start of the list. In addition, if there are specific
62-
* accessors that exactly name the class in question and accessors that name
63-
* a specific class which is a supertype of the class in question, the latter
64-
* are put at the end of the specific accessors set and will be tried after
65-
* exactly matching accessors but before generic accessors.
58+
* <p>The supplied accessors are considered to be in an ordered list; however,
59+
* in the returned list any accessors that are exact matches for the supplied
60+
* target type are placed at the start of the list (as opposed to 'generic'
61+
* accessors that could work for any target type). In addition, if there are
62+
* accessors that claim support for the exact target type as well as accessors
63+
* that claim support for a supertype of the target type, the latter are placed
64+
* at the end of the specific accessors set and will be tried after exactly
65+
* matching accessors but before generic accessors.
66+
* <p>Only matching accessors and generic accessors will be included in the
67+
* returned list.
6668
* @param targetType the type upon which element access is being attempted
6769
* @param accessors the list of element accessors to process
6870
* @return a list of accessors that should be tried in order to access the
6971
* element on the specified target type, or an empty list if no suitable
7072
* accessor could be found
7173
* @since 6.2
74+
* @see TargetedAccessor#getSpecificTargetClasses()
7275
*/
7376
static <T extends TargetedAccessor> List<T> getAccessorsToTry(
7477
@Nullable Class<?> targetType, List<T> accessors) {

0 commit comments

Comments
 (0)