Polish SpEL documentation
This commit is contained in:
parent
a12d40e10b
commit
7196f3f554
|
@ -12,12 +12,12 @@ Java::
|
|||
+
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
Inventor einstein = p.parseExpression(
|
||||
Inventor einstein = parser.parseExpression(
|
||||
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
|
||||
.getValue(Inventor.class);
|
||||
|
||||
// create new Inventor instance within the add() method of List
|
||||
p.parseExpression(
|
||||
parser.parseExpression(
|
||||
"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
|
||||
.getValue(societyContext);
|
||||
----
|
||||
|
@ -26,12 +26,12 @@ Kotlin::
|
|||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
val einstein = p.parseExpression(
|
||||
val einstein = parser.parseExpression(
|
||||
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
|
||||
.getValue(Inventor::class.java)
|
||||
|
||||
// create new Inventor instance within the add() method of List
|
||||
p.parseExpression(
|
||||
parser.parseExpression(
|
||||
"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
|
||||
.getValue(societyContext)
|
||||
----
|
||||
|
|
|
@ -151,10 +151,10 @@ Kotlin::
|
|||
----
|
||||
======
|
||||
|
||||
As hinted above, binding a `MethodHandle` and registering the bound `MethodHandle` is also
|
||||
supported. This is likely to be more performant if both the target and all the arguments
|
||||
are bound. In that case no arguments are necessary in the SpEL expression, as the
|
||||
following example shows:
|
||||
As mentioned above, binding a `MethodHandle` and registering the bound `MethodHandle` is
|
||||
also supported. This is likely to be more performant if both the target and all the
|
||||
arguments are bound. In that case no arguments are necessary in the SpEL expression, as
|
||||
the following example shows:
|
||||
|
||||
[tabs]
|
||||
======
|
||||
|
@ -170,7 +170,8 @@ Java::
|
|||
MethodHandle mh = MethodHandles.lookup().findVirtual(String.class, "formatted",
|
||||
MethodType.methodType(String.class, Object[].class))
|
||||
.bindTo(template)
|
||||
.bindTo(varargs); //here we have to provide arguments in a single array binding
|
||||
// Here we have to provide the arguments in a single array binding:
|
||||
.bindTo(varargs);
|
||||
context.setVariable("message", mh);
|
||||
|
||||
// evaluates to "This is a prerecorded message with 3 words: <Oh Hello World!>"
|
||||
|
@ -191,7 +192,8 @@ Kotlin::
|
|||
val mh = MethodHandles.lookup().findVirtual(String::class.java, "formatted",
|
||||
MethodType.methodType(String::class.java, Array<Any>::class.java))
|
||||
.bindTo(template)
|
||||
.bindTo(varargs) //here we have to provide arguments in a single array binding
|
||||
// Here we have to provide the arguments in a single array binding:
|
||||
.bindTo(varargs)
|
||||
context.setVariable("message", mh)
|
||||
|
||||
// evaluates to "This is a prerecorded message with 3 words: <Oh Hello World!>"
|
||||
|
|
|
@ -36,6 +36,8 @@ import static org.assertj.core.api.Assertions.assertThatException;
|
|||
* Tests invocation of constructors.
|
||||
*
|
||||
* @author Andy Clement
|
||||
* @see MethodInvocationTests
|
||||
* @see VariableAndFunctionTests
|
||||
*/
|
||||
class ConstructorInvocationTests extends AbstractExpressionTests {
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
|||
* @author Andy Clement
|
||||
* @author Phillip Webb
|
||||
* @author Sam Brannen
|
||||
* @see ConstructorInvocationTests
|
||||
* @see VariableAndFunctionTests
|
||||
*/
|
||||
class MethodInvocationTests extends AbstractExpressionTests {
|
||||
|
||||
|
|
|
@ -658,7 +658,8 @@ class SpelDocumentationTests extends AbstractExpressionTests {
|
|||
MethodHandle methodHandle = MethodHandles.lookup().findVirtual(String.class, "formatted",
|
||||
MethodType.methodType(String.class, Object[].class))
|
||||
.bindTo(template)
|
||||
.bindTo(varargs); // here we have to provide arguments in a single array binding
|
||||
// Here we have to provide the arguments in a single array binding:
|
||||
.bindTo(varargs);
|
||||
context.registerFunction("message", methodHandle);
|
||||
|
||||
String message = parser.parseExpression("#message()").getValue(context, String.class);
|
||||
|
|
|
@ -32,6 +32,8 @@ import static org.springframework.expression.spel.SpelMessage.INCORRECT_NUMBER_O
|
|||
*
|
||||
* @author Andy Clement
|
||||
* @author Sam Brannen
|
||||
* @see ConstructorInvocationTests
|
||||
* @see MethodInvocationTests
|
||||
*/
|
||||
class VariableAndFunctionTests extends AbstractExpressionTests {
|
||||
|
||||
|
|
Loading…
Reference in New Issue