Skip to content

Commit 92874ad

Browse files
committed
Polish SpEL documentation
(cherry picked from commit 7196f3f)
1 parent 55167b7 commit 92874ad

File tree

6 files changed

+25
-16
lines changed

6 files changed

+25
-16
lines changed

Diff for: framework-docs/modules/ROOT/pages/core/expressions/language-ref/constructors.adoc

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Java::
1212
+
1313
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
1414
----
15-
Inventor einstein = p.parseExpression(
16-
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
15+
Inventor einstein = parser.parseExpression(
16+
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
1717
.getValue(Inventor.class);
1818
1919
// create new Inventor instance within the add() method of List
20-
p.parseExpression(
20+
parser.parseExpression(
2121
"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
2222
.getValue(societyContext);
2323
----
@@ -26,13 +26,13 @@ Kotlin::
2626
+
2727
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
2828
----
29-
val einstein = p.parseExpression(
30-
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
29+
val einstein = parser.parseExpression(
30+
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
3131
.getValue(Inventor::class.java)
3232
3333
// create new Inventor instance within the add() method of List
34-
p.parseExpression(
35-
"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
34+
parser.parseExpression(
35+
"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
3636
.getValue(societyContext)
3737
----
3838
======

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

+10-8
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ Kotlin::
151151
----
152152
======
153153

154-
As hinted above, binding a `MethodHandle` and registering the bound `MethodHandle` is also
155-
supported. This is likely to be more performant if both the target and all the arguments
156-
are bound. In that case no arguments are necessary in the SpEL expression, as the
157-
following example shows:
154+
As mentioned above, binding a `MethodHandle` and registering the bound `MethodHandle` is
155+
also supported. This is likely to be more performant if both the target and all the
156+
arguments are bound. In that case no arguments are necessary in the SpEL expression, as
157+
the following example shows:
158158

159159
[tabs]
160160
======
@@ -168,9 +168,10 @@ Java::
168168
String template = "This is a %s message with %s words: <%s>";
169169
Object varargs = new Object[] { "prerecorded", 3, "Oh Hello World!", "ignored" };
170170
MethodHandle mh = MethodHandles.lookup().findVirtual(String.class, "formatted",
171-
MethodType.methodType(String.class, Object[].class))
171+
MethodType.methodType(String.class, Object[].class))
172172
.bindTo(template)
173-
.bindTo(varargs); //here we have to provide arguments in a single array binding
173+
// Here we have to provide the arguments in a single array binding:
174+
.bindTo(varargs);
174175
context.setVariable("message", mh);
175176
176177
// evaluates to "This is a prerecorded message with 3 words: <Oh Hello World!>"
@@ -189,9 +190,10 @@ Kotlin::
189190
val varargs = arrayOf("prerecorded", 3, "Oh Hello World!", "ignored")
190191
191192
val mh = MethodHandles.lookup().findVirtual(String::class.java, "formatted",
192-
MethodType.methodType(String::class.java, Array<Any>::class.java))
193+
MethodType.methodType(String::class.java, Array<Any>::class.java))
193194
.bindTo(template)
194-
.bindTo(varargs) //here we have to provide arguments in a single array binding
195+
// Here we have to provide the arguments in a single array binding:
196+
.bindTo(varargs)
195197
context.setVariable("message", mh)
196198
197199
// evaluates to "This is a prerecorded message with 3 words: <Oh Hello World!>"

Diff for: spring-expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
* Tests invocation of constructors.
3737
*
3838
* @author Andy Clement
39+
* @see MethodInvocationTests
40+
* @see VariableAndFunctionTests
3941
*/
4042
class ConstructorInvocationTests extends AbstractExpressionTests {
4143

Diff for: spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
* @author Andy Clement
4747
* @author Phillip Webb
4848
* @author Sam Brannen
49+
* @see ConstructorInvocationTests
50+
* @see VariableAndFunctionTests
4951
*/
5052
class MethodInvocationTests extends AbstractExpressionTests {
5153

Diff for: spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,8 @@ void registerFunctionViaMethodHandleFullyBound() throws Exception {
597597
MethodHandle methodHandle = MethodHandles.lookup().findVirtual(String.class, "formatted",
598598
MethodType.methodType(String.class, Object[].class))
599599
.bindTo(template)
600-
.bindTo(varargs); // here we have to provide arguments in a single array binding
600+
// Here we have to provide the arguments in a single array binding:
601+
.bindTo(varargs);
601602
context.registerFunction("message", methodHandle);
602603

603604
String message = parser.parseExpression("#message()").getValue(context, String.class);

Diff for: spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
*
3333
* @author Andy Clement
3434
* @author Sam Brannen
35+
* @see ConstructorInvocationTests
36+
* @see MethodInvocationTests
3537
*/
3638
class VariableAndFunctionTests extends AbstractExpressionTests {
3739

0 commit comments

Comments
 (0)