defined

The defined test checks if a variable exists.

Example

{%if someVar is defined%}   
...
{%endif %}

empty

The empty test checks if a variable is empty. A variable is empty if it is null, an empty string, an empty collection, or an empty map.

Example

{% if "" is empty %}   
...
{% endif %}

even

The even test checks if an integer is even.

Example

{% if 2 is even %}   
...
{% endif %}

iterable

The iterable test checks if a variable implements java.lang.Iterable.

Example

{% if [ "a", "b", "c" ] is iterable %}
...
{% endif %}

map

The map test checks if a variable is an instance of a map.

Example

{% if { "a": "aa", "b": "bb" } is map %}   
...
{% endif %}

null

The null test checks if a variable is null.

Example

{% if someVar is null %}   
...
{% endif %}

odd

The odd test checks if an integer is odd.

Example

{% if "" is odd %}   
...
{% endif %}

boolean

The boolean test checks if the input is a Boolean or viable to be casted as a Boolean.

Example

{% if "yes" is boolean %}   
...
{% endif %}


Example 2

{% if 1 is boolean %}   
...
{% endif %}

instanceof

The instanceof test checks if the input is of the specified class.

Example

{% if "a" is instanceof ("String") %}   
...
{% endif %}


Example 2

{% if "a" is instanceof ("java.lang.String") %}   
...
{% endif %}

number

The number test checks if the input is a Number or viable to be casted as a Number. The input can be either a numeric value or a String.

Example

{% if3.14 is number %}   
...
{% endif %}


Example 2

{% if "3.14" is number %}   
...
{% endif %}

string

The string test checks if the input is a String.

Example

{% if "a" is string %}
...
{% endif %}

  • No labels