|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
19 | 19 | import org.springframework.lang.Nullable;
|
20 | 20 |
|
21 | 21 | /**
|
22 |
| - * A property accessor is able to read from (and possibly write to) an object's properties. |
| 22 | + * A property accessor is able to read from (and possibly write to) an object's |
| 23 | + * properties. |
23 | 24 | *
|
24 |
| - * <p>This interface places no restrictions, and so implementors are free to access properties |
25 |
| - * directly as fields or through getters or in any other way they see as appropriate. |
| 25 | + * <p>This interface places no restrictions on what constitutes a property. |
| 26 | + * Implementors are therefore free to access properties directly via fields, |
| 27 | + * through getters, or in any other way they deem appropriate. |
26 | 28 | *
|
27 |
| - * <p>A resolver can optionally specify an array of target classes for which it should be |
28 |
| - * called. However, if it returns {@code null} from {@link #getSpecificTargetClasses()}, |
29 |
| - * it will be called for all property references and given a chance to determine if it |
30 |
| - * can read or write them. |
| 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. |
31 | 33 | *
|
32 |
| - * <p>Property resolvers are considered to be ordered, and each will be called in turn. |
33 |
| - * The only rule that affects the call order is that any resolver naming the target |
34 |
| - * class directly in {@link #getSpecificTargetClasses()} will be called first, before |
35 |
| - * the general resolvers. |
| 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 general |
| 38 | + * property accessors. |
36 | 39 | *
|
37 | 40 | * @author Andy Clement
|
38 | 41 | * @since 3.0
|
39 | 42 | */
|
40 | 43 | public interface PropertyAccessor {
|
41 | 44 |
|
42 | 45 | /**
|
43 |
| - * Return an array of classes for which this resolver should be called. |
44 |
| - * <p>Returning {@code null} indicates this is a general resolver that |
| 46 | + * Return an array of classes for which this property accessor should be called. |
| 47 | + * <p>Returning {@code null} indicates this is a general property accessor that |
45 | 48 | * can be called in an attempt to resolve a property on any type.
|
46 |
| - * @return an array of classes that this resolver is suitable for |
47 |
| - * (or {@code null} if a general resolver) |
| 49 | + * @return an array of classes that this property accessor is suitable for |
| 50 | + * (or {@code null} if a general property accessor) |
48 | 51 | */
|
49 | 52 | @Nullable
|
50 | 53 | Class<?>[] getSpecificTargetClasses();
|
51 | 54 |
|
52 | 55 | /**
|
53 |
| - * Called to determine if a resolver instance is able to access a specified property |
54 |
| - * on a specified target object. |
| 56 | + * Called to determine if this property accessor is able to read a specified |
| 57 | + * property on a specified target object. |
55 | 58 | * @param context the evaluation context in which the access is being attempted
|
56 | 59 | * @param target the target object upon which the property is being accessed
|
57 | 60 | * @param name the name of the property being accessed
|
58 |
| - * @return true if this resolver is able to read the property |
59 |
| - * @throws AccessException if there is any problem determining whether the property can be read |
| 61 | + * @return true if this property accessor is able to read the property |
| 62 | + * @throws AccessException if there is any problem determining whether the |
| 63 | + * property can be read |
60 | 64 | */
|
61 | 65 | boolean canRead(EvaluationContext context, @Nullable Object target, String name) throws AccessException;
|
62 | 66 |
|
63 | 67 | /**
|
64 | 68 | * Called to read a property from a specified target object.
|
65 |
| - * Should only succeed if {@link #canRead} also returns {@code true}. |
| 69 | + * <p>Should only succeed if {@link #canRead} also returns {@code true}. |
66 | 70 | * @param context the evaluation context in which the access is being attempted
|
67 | 71 | * @param target the target object upon which the property is being accessed
|
68 | 72 | * @param name the name of the property being accessed
|
69 |
| - * @return a TypedValue object wrapping the property value read and a type descriptor for it |
70 |
| - * @throws AccessException if there is any problem accessing the property value |
| 73 | + * @return a TypedValue object wrapping the property value read and a type |
| 74 | + * descriptor for it |
| 75 | + * @throws AccessException if there is any problem reading the property value |
71 | 76 | */
|
72 | 77 | TypedValue read(EvaluationContext context, @Nullable Object target, String name) throws AccessException;
|
73 | 78 |
|
74 | 79 | /**
|
75 |
| - * Called to determine if a resolver instance is able to write to a specified |
| 80 | + * Called to determine if this property accessor is able to write to a specified |
76 | 81 | * property on a specified target object.
|
77 | 82 | * @param context the evaluation context in which the access is being attempted
|
78 | 83 | * @param target the target object upon which the property is being accessed
|
79 | 84 | * @param name the name of the property being accessed
|
80 |
| - * @return true if this resolver is able to write to the property |
| 85 | + * @return true if this property accessor is able to write to the property |
81 | 86 | * @throws AccessException if there is any problem determining whether the
|
82 | 87 | * property can be written to
|
83 | 88 | */
|
84 | 89 | boolean canWrite(EvaluationContext context, @Nullable Object target, String name) throws AccessException;
|
85 | 90 |
|
86 | 91 | /**
|
87 | 92 | * Called to write to a property on a specified target object.
|
88 |
| - * Should only succeed if {@link #canWrite} also returns {@code true}. |
| 93 | + * <p>Should only succeed if {@link #canWrite} also returns {@code true}. |
89 | 94 | * @param context the evaluation context in which the access is being attempted
|
90 | 95 | * @param target the target object upon which the property is being accessed
|
91 | 96 | * @param name the name of the property being accessed
|
|
0 commit comments