Skip to content

Commit 10bc93c

Browse files
committed
Polishing
1 parent 9b93c94 commit 10bc93c

File tree

7 files changed

+21
-15
lines changed

7 files changed

+21
-15
lines changed

framework-docs/modules/ROOT/pages/core/expressions/language-ref/functions.adoc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Kotlin::
5555
----
5656
======
5757

58-
You can then register and use the preceding method, as the following example shows:
58+
You can register and use the preceding method, as the following example shows:
5959

6060
[tabs]
6161
======
@@ -67,8 +67,9 @@ Java::
6767
6868
EvaluationContext context = SimpleEvaluationContext.forReadOnlyDataBinding().build();
6969
context.setVariable("reverseString",
70-
StringUtils.class.getDeclaredMethod("reverseString", String.class));
70+
StringUtils.class.getMethod("reverseString", String.class));
7171
72+
// evaluates to "olleh"
7273
String helloWorldReversed = parser.parseExpression(
7374
"#reverseString('hello')").getValue(context, String.class);
7475
----
@@ -80,16 +81,18 @@ Kotlin::
8081
val parser = SpelExpressionParser()
8182
8283
val context = SimpleEvaluationContext.forReadOnlyDataBinding().build()
83-
context.setVariable("reverseString", ::reverseString::javaMethod)
84+
context.setVariable("reverseString", ::reverseString.javaMethod)
8485
86+
// evaluates to "olleh"
8587
val helloWorldReversed = parser.parseExpression(
8688
"#reverseString('hello')").getValue(context, String::class.java)
8789
----
8890
======
8991

90-
The use of `MethodHandle` is also supported. This enables potentially more efficient use
91-
cases if the `MethodHandle` target and parameters have been fully bound prior to
92-
registration, but partially bound handles are also supported.
92+
A function can also be registered as a `java.lang.invoke.MethodHandle`. This enables
93+
potentially more efficient use cases if the `MethodHandle` target and parameters have
94+
been fully bound prior to registration; however, partially bound handles are also
95+
supported.
9396

9497
Consider the `String#formatted(String, Object...)` instance method, which produces a
9598
message according to a template and a variable number of arguments.
@@ -110,9 +113,9 @@ Java::
110113
MethodType.methodType(String.class, Object[].class));
111114
context.setVariable("message", mh);
112115
116+
// evaluates to "Simple message: <Hello World>"
113117
String message = parser.parseExpression("#message('Simple message: <%s>', 'Hello World', 'ignored')")
114118
.getValue(context, String.class);
115-
//returns "Simple message: <Hello World>"
116119
----
117120
118121
Kotlin::
@@ -126,6 +129,7 @@ Kotlin::
126129
MethodType.methodType(String::class.java, Array<Any>::class.java))
127130
context.setVariable("message", mh)
128131
132+
// evaluates to "Simple message: <Hello World>"
129133
val message = parser.parseExpression("#message('Simple message: <%s>', 'Hello World', 'ignored')")
130134
.getValue(context, String::class.java)
131135
----

framework-docs/modules/ROOT/pages/web/webflux-functional.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ Kotlin::
787787

788788
WebFlux.fn provides built-in support for serving resources.
789789

790-
NOTE: In addition to the capabilities described below, it is possible to implement an even more flexible resource handling thanks to
790+
NOTE: In addition to the capabilities described below, it is possible to implement even more flexible resource handling thanks to
791791
{spring-framework-api}++/web/reactive/function/server/RouterFunctions.html#resources(java.util.function.Function)++[`RouterFunctions#resource(java.util.function.Function)`].
792792

793793
[[webflux-fn-resource]]

framework-docs/modules/ROOT/pages/web/webmvc-functional.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ Kotlin::
765765

766766
WebMvc.fn provides built-in support for serving resources.
767767

768-
NOTE: In addition to the capabilities described below, it is possible to implement an even more flexible resource handling thanks to
768+
NOTE: In addition to the capabilities described below, it is possible to implement even more flexible resource handling thanks to
769769
{spring-framework-api}++/web/servlet/function/RouterFunctions.html#resources(java.util.function.Function)++[`RouterFunctions#resource(java.util.function.Function)`].
770770

771771
[[webmvc-fn-resource]]

spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
/**
4242
* Register the necessary reflection hints so that the specified type can be
43-
* bound at runtime. Fields, constructors, properties and record components
43+
* bound at runtime. Fields, constructors, properties, and record components
4444
* are registered, except for a set of types like those in the {@code java.}
4545
* package where just the type is registered. Types are discovered transitively
4646
* on properties and record components, and generic types are registered as well.
@@ -200,9 +200,9 @@ private void forEachJacksonAnnotation(AnnotatedElement element, Consumer<MergedA
200200
}
201201

202202
private void registerHintsForClassAttributes(ReflectionHints hints, MergedAnnotation<Annotation> annotation) {
203-
annotation.getRoot().asMap().forEach((key,value) -> {
203+
annotation.getRoot().asMap().forEach((attributeName, value) -> {
204204
if (value instanceof Class<?> classValue && value != Void.class) {
205-
if (key.equals("builder")) {
205+
if (attributeName.equals("builder")) {
206206
hints.registerType(classValue, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
207207
MemberCategory.INVOKE_DECLARED_METHODS);
208208
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ default TypedValue assignVariable(String name, Supplier<TypedValue> valueSupplie
121121
* configuration for the context.
122122
* @param name the name of the variable to set
123123
* @param value the value to be placed in the variable
124+
* @see #lookupVariable(String)
124125
*/
125126
void setVariable(String name, @Nullable Object value);
126127

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
* @see StandardEvaluationContext
8888
* @see StandardTypeConverter
8989
* @see DataBindingPropertyAccessor
90+
* @see DataBindingMethodResolver
9091
*/
9192
public final class SimpleEvaluationContext implements EvaluationContext {
9293

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public void setVariable(@Nullable String name, @Nullable Object value) {
269269
}
270270

271271
/**
272-
* Set multiple named variables in this evaluation context to given values.
272+
* Set multiple named variables in this evaluation context to the specified values.
273273
* <p>This is a convenience variant of {@link #setVariable(String, Object)}.
274274
* @param variables the names and values of the variables to set
275275
* @see #setVariable(String, Object)
@@ -284,7 +284,7 @@ public void setVariables(Map<String, Object> variables) {
284284
* evaluation context, as populated by {@link #setVariable(String, Object)}.
285285
* Make sure that specified function names and variable names do not overlap.
286286
* @param name the name of the function
287-
* @param method the Method to register
287+
* @param method the {@code Method} to register
288288
* @see #registerFunction(String, MethodHandle)
289289
*/
290290
public void registerFunction(String name, Method method) {
@@ -297,7 +297,7 @@ public void registerFunction(String name, Method method) {
297297
* evaluation context, as populated by {@link #setVariable(String, Object)}.
298298
* Make sure that specified function names and variable names do not overlap.
299299
* @param name the name of the function
300-
* @param methodHandle the MethodHandle to register
300+
* @param methodHandle the {@link MethodHandle} to register
301301
* @since 6.1
302302
* @see #registerFunction(String, Method)
303303
*/

0 commit comments

Comments
 (0)