Skip to content

Commit

Permalink
Improve documentation for alternative textual operators in SpEL
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jan 29, 2024
1 parent 9eae0ba commit e97fc7b
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The Spring Expression Language supports the following kinds of operators:
The relational operators (equal, not equal, less than, less than or equal, greater than,
and greater than or equal) are supported by using standard operator notation.
These operators work on `Number` types as well as types implementing `Comparable`.
The following listing shows a few examples of operators:
The following listing shows a few examples of relational operators:

[tabs]
======
Expand Down Expand Up @@ -67,7 +67,7 @@ in favor of comparisons against zero (for example, `X > 0` or `X < 0`).
====

In addition to the standard relational operators, SpEL supports the `instanceof` and regular
expression-based `matches` operator. The following listing shows examples of both:
expression-based `matches` operators. The following listing shows examples of both:

[tabs]
======
Expand Down Expand Up @@ -108,21 +108,19 @@ Kotlin::

CAUTION: Be careful with primitive types, as they are immediately boxed up to their
wrapper types. For example, `1 instanceof T(int)` evaluates to `false`, while
`1 instanceof T(Integer)` evaluates to `true`, as expected.
`1 instanceof T(Integer)` evaluates to `true`.

Each symbolic operator can also be specified as a purely alphabetic equivalent. This
avoids problems where the symbols used have special meaning for the document type in
which the expression is embedded (such as in an XML document). The textual equivalents are:
Each symbolic operator can also be specified as a purely textual equivalent. This avoids
problems where the symbols used have special meaning for the document type in which the
expression is embedded (such as in an XML document). The textual equivalents are:

* `lt` (`<`)
* `gt` (`>`)
* `le` (`\<=`)
* `ge` (`>=`)
* `eq` (`==`)
* `ne` (`!=`)
* `div` (`/`)
* `mod` (`%`)
* `not` (`!`).
* `not` (`!`)

All of the textual operators are case-insensitive.

Expand All @@ -136,6 +134,8 @@ SpEL supports the following logical operators:
* `or` (`||`)
* `not` (`!`)

All of the textual operators are case-insensitive.

The following example shows how to use the logical operators:

[tabs]
Expand Down Expand Up @@ -283,6 +283,16 @@ You can use the following operators on numbers, and standard operator precedence
* modulus (`%`)
* exponential power (`^`)

The division and modulus operators can also be specified as a purely textual equivalent.
This avoids problems where the symbols used have special meaning for the document type in
which the expression is embedded (such as in an XML document). The textual equivalents
are:

* `div` (`/`)
* `mod` (`%`)

All of the textual operators are case-insensitive.

[NOTE]
====
The increment and decrement operators can be used with either prefix (`{pp}A`, `--A`) or
Expand Down

0 comments on commit e97fc7b

Please sign in to comment.