Skip to content

Utility functions

Oswaldo Baptista Vicente Junior edited this page Oct 21, 2022 · 1 revision

Distinct

Returns a list consisting of the distinct elements of a given vector, list, array or JSON array.

distinct(["say", "what", "you", "need", "to", "say"]) //result: ["say", "what", "you", "need", "to"]

Get Environment Variable

Returns the value of an environment variable associated with the given key in the Operating System.

getEnv("TEMP")

Get System Property

Returns the value of system property associated with the given key.

getSystemProperty("os.name")

Is Decimal

Returns 1 (true) if the given parameter is a number (or string representing a number) containing decimals.

isDecimal(10.333) //returns: 1.0
isDecimal(999.0)  //returns: 0.0
isDecimal("10.3") //returns: 1.0
isDecimal("1.0")  //returns: 0.0

Is Empty

Returns 1 (true) if the given parameter is either a null object or an empty String, JSON or Collection.

If a given string can be parsed as JSON object or array, it will be first converted into JSON, then its structure will be evaluated for emptiness.

isEmpty("")   //returns: 1.0
isEmpty("{}") //returns: 1.0
isEmpty("[]") //returns: 1.0

Is Integer

Returns 1 (true) if the given parameter is a number (or string representing a number) is a whole number (which lacks decimals).

isInteger(10.0)  //returns: 1.0
isInteger(9.90)  //returns: 0.0
isInteger("1.0") //returns: 1.0
isInteger("0.3") //returns: 0.0

Read file

Returns the content of a text file in the file system.

readFile("/tmp/data.json")

Type of

Returns the Java type associated with the given variable

typeOf("text") //result: "java.lang.String"

Note: Also achievable using the alias class.