Skip to content

Commit

Permalink
Fix wording in SpEL's PropertyAccessor Javadoc
Browse files Browse the repository at this point in the history
The documentation now properly refers to "property accessors" instead
of "resolvers".
  • Loading branch information
sbrannen committed Mar 25, 2024
1 parent 7c009cc commit 57632f9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @author Andy Clement
* @author Sam Brannen
* @since 3.0
* @see ConstructorResolver
* @see MethodResolver
* @see MethodExecutor
*/
@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
* you may not use this file except in compliance with the License.
Expand All @@ -19,73 +19,78 @@
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
* directly as fields or through getters or in any other way they see as appropriate.
* <p>This interface places no restrictions on what constitutes a property.
* 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
* called. However, if it returns {@code null} from {@link #getSpecificTargetClasses()},
* it will be called for all property references and given a chance to determine if it
* can read or write them.
* <p>A property accessor can optionally specify an array of target classes for
* which it should be called. However, if it returns {@code null} from
* {@link #getSpecificTargetClasses()}, it will be called for all property
* 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.
* The only rule that affects the call order is that any resolver naming the target
* class directly in {@link #getSpecificTargetClasses()} will be called first, before
* the general resolvers.
* <p>Property accessors are considered to be ordered, and each will be called in
* turn. The only rule that affects the call order is that any property accessor
* which specifies explicit support for the target class via
* {@link #getSpecificTargetClasses()} will be called first, before the general
* property accessors.
*
* @author Andy Clement
* @since 3.0
*/
public interface PropertyAccessor {

/**
* Return an array of classes for which this resolver should be called.
* <p>Returning {@code null} indicates this is a general resolver that
* Return an array of classes for which this property accessor should be called.
* <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.
* @return an array of classes that this resolver is suitable for
* (or {@code null} if a general resolver)
* @return an array of classes that this property accessor is suitable for
* (or {@code null} if a general property accessor)
*/
@Nullable
Class<?>[] getSpecificTargetClasses();

/**
* Called to determine if a resolver instance is able to access a specified property
* on a specified target object.
* Called to determine if this property accessor is able to read a specified
* property on a specified target object.
* @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 name the name of the property being accessed
* @return true if this resolver is able to read the property
* @throws AccessException if there is any problem determining whether the property can be read
* @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
*/
boolean canRead(EvaluationContext context, @Nullable Object target, String name) throws AccessException;

/**
* 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 target the target object upon which the property is 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
* @throws AccessException if there is any problem accessing the property value
* @return a TypedValue object wrapping the property value read and a type
* 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;

/**
* 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.
* @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 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
* property can be written to
*/
boolean canWrite(EvaluationContext context, @Nullable Object target, String name) throws AccessException;

/**
* 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 target the target object upon which the property is being accessed
* @param name the name of the property being accessed
Expand Down

0 comments on commit 57632f9

Please sign in to comment.