Skip to content

Commit b431594

Browse files
committed
Make SpEL's OptimalPropertyAccessor private
It was never necessary for SpEL's OptimalPropertyAccessor to be public. Instead, clients should interact with OptimalPropertyAccessor exclusively via the CompilablePropertyAccessor API. In light of that, this commit makes SpEL's OptimalPropertyAccessor private. Closes gh-32410
1 parent fc88522 commit b431594

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectivePropertyAccessor.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -504,15 +504,16 @@ protected Field findField(String name, Class<?> clazz, boolean mustBeStatic) {
504504
}
505505

506506
/**
507-
* Attempt to create an optimized property accessor tailored for a property of a
508-
* particular name on a particular class. The general ReflectivePropertyAccessor
509-
* will always work but is not optimal due to the need to lookup which reflective
510-
* member (method/field) to use each time read() is called. This method will just
511-
* return the ReflectivePropertyAccessor instance if it is unable to build a more
512-
* optimal accessor.
513-
* <p>Note: An optimal accessor is currently only usable for read attempts.
507+
* Attempt to create an optimized property accessor tailored for a property
508+
* of a particular name on a particular class.
509+
* <p>The general {@link ReflectivePropertyAccessor} will always work but is
510+
* not optimal due to the need to look up which reflective member (method or
511+
* field) to use each time {@link #read(EvaluationContext, Object, String)}
512+
* is called.
513+
* <p>This method will return this {@code ReflectivePropertyAccessor} instance
514+
* if it is unable to build a optimized accessor.
515+
* <p>Note: An optimized accessor is currently only usable for read attempts.
514516
* Do not call this method if you need a read-write accessor.
515-
* @see OptimalPropertyAccessor
516517
*/
517518
public PropertyAccessor createOptimalAccessor(EvaluationContext context, @Nullable Object target, String name) {
518519
// Don't be clever for arrays or a null target...
@@ -597,19 +598,20 @@ public int compareTo(PropertyCacheKey other) {
597598

598599

599600
/**
600-
* An optimized form of a PropertyAccessor that will use reflection but only knows
601-
* how to access a particular property on a particular class. This is unlike the
602-
* general ReflectivePropertyResolver which manages a cache of methods/fields that
603-
* may be invoked to access different properties on different classes. This optimal
604-
* accessor exists because looking up the appropriate reflective object by class/name
605-
* on each read is not cheap.
601+
* An optimized {@link CompilablePropertyAccessor} that will use reflection
602+
* but only knows how to access a particular property on a particular class.
603+
* <p>This is unlike the general {@link ReflectivePropertyAccessor} which
604+
* manages a cache of methods and fields that may be invoked to access
605+
* different properties on different classes.
606+
* <p>This optimized accessor exists because looking up the appropriate
607+
* reflective method or field on each read is not cheap.
606608
*/
607-
public static class OptimalPropertyAccessor implements CompilablePropertyAccessor {
609+
private static class OptimalPropertyAccessor implements CompilablePropertyAccessor {
608610

609611
/**
610612
* The member being accessed.
611613
*/
612-
public final Member member;
614+
private final Member member;
613615

614616
private final TypeDescriptor typeDescriptor;
615617

0 commit comments

Comments
 (0)