SpEL Built-in Functions
Introduction
This chapter is a complete reference to SpEL built-in functions—the ready-to-use helpers that are always at your fingertips while writing tSM expressions. You will find two kinds of helpers here:
-
Type extensions – methods that extend everyday data types such as strings, numbers, dates, lists, sets and maps. They read naturally:
'Hello'.uppercase() // "HELLO"
[1,2,3].sum() // 6 (example only) -
Standalone functions – utilities that are not tied to any specific value and are invoked with the
#prefix:#now() // current date-time
#randomUUID() // e.g. "8e29…"
#if(#total > 100).then('Large')...
All functions described in this chapter are available anywhere SpEL is evaluated—inside console experiments, mapping scripts, conditions, service calls, process gateways, and more. Use the tables below to scan each group quickly: signature in the first column, behavior in the second, plus compact examples at the end of every section.
1 String
| Method | Signature | Description |
|---|---|---|
| contains | (other :String, ignoreCase :Boolean =false): Boolean | Returns true when other is found inside the string. Set ignoreCase=true to ignore case. |
| startsWith | (other :String, ignoreCase :Boolean =false): Boolean | Returns true if the string begins with other. Case‑insensitive when ignoreCase is true. |
| isEmpty / isNotEmpty | (): Boolean | isEmpty is true when the string length is zero. isNotEmpty is the opposite. |
| isBlank / isNotBlank | (): Boolean | isBlank is true when the string is empty or consists solely of whitespace. isNotBlank is the opposite. |
| length | (): Int | Number of characters in the string. |
| lowercase / uppercase | (): String | Converts all alphabetic characters to lower/upper case. |
| padStart | (length :Int, padChar :Char =' '): String | Left‑pads the string with padChar until it reaches length. |
| replace | (oldValue :String, newValue :String): String | Returns a copy of the string with every occurrence of oldValue replaced by newValue. |
| toBoolean | (): Boolean | true when the string equals "true" (ignoring case), otherwise false. |
| toInt / toLong | (): Int / Long | Parses the string as a signed decimal number. Throws error if not numeric. |
| decodeBase64 | (): ByteArray | Decodes Base‑64 text into raw bytes. |
| toByteArray | (): ByteArray | Converts the string to a byte array using the default character set of the system. |
| toUuid | (): UUID | Converts a canonical UUID string into a UUID object. |
| toJsonNode | (): JsonNode | Parses JSON text and returns a tree model (JsonNode) for flexible navigation. |
| toJsonObject | (): Any | Parses JSON text into plain collections: objects → Map, arrays → List, primitives stay primitive. |
| toDate | (format :String): Date | Parses the string as a date/time using the supplied format pattern. |
(): Date | Parses the string as an ISO‑8601 date/time with offset. | |
| parse | (regexPattern :String): Map<String,String>? | Matches the string against regexPattern (may contain named groups). Returns a map of capture name → text, or null if no match. |
Examples
'+1 234'.parse("\\+(?<cc>\\d{1,3})\\s+(?<num>.*)")
// → {'cc':'1','num':'234'}
' '.isBlank() // true
'7'.padStart(3,'0') // '007'
2 List & Set
| Method | Signature | Description |
|---|---|---|
| forEach | (varRef, expr1, expr2, …): List | Iterates over each element, evaluating the expressions in the context of that element. The first argument must be a variable reference (e.g. #item). A special variable #index holds the position. The last expression’s value for each element is collected into the resulting list. |
| filter | (predicateExpr): List<T> | Keeps elements for which predicateExpr evaluates to true. Inside the predicate you can use it and index. |
| size / get / indexOf / first / last | see signature | Standard collection helpers. |
| distinct / distinctCount | (): List<T> / (): Map<T,Int> | Removes duplicates (distinct) or counts occurrences (distinctCount). |
| sorted / reversed / min / max | (): … | Returns a sorted copy, a reversed copy, or the minimum/maximum element using natural ordering. |
| take / drop / subList | |