Skip to content

Home

Development

IDEs

JAR services

API Explorer

BooleanFunctions

The Boolean class contains functions for handling boolean primitives and Boolean objects in Gloop.

Recommended for use in Gloop only

In Groovy, you can use functions from the org.apache.commons.lang3.BooleanUtils class instead for your boolean-operation needs. Boolean extends this class but adds a few more functions. Their contents are more or less the same.

You can use these functions in both Gloop and Groovy. Below is a snippet showing how to use Boolean's instance extension functions:

Sample service showing how to use the `Boolean` functions

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Declare object containing boolean value
Object object = "true"

// Convert object to boolean
def objectBoolean = object.toBoolean()

// Assert that the value is true
assert objectBoolean == true

// Declare string containg boolean value
String string = "false"

// Convert string to boolean
def stringBoolean = string.toBoolean()

// Assert that the value is false
assert stringBoolean == false

// Create an array containing the two values
boolean[] bools = [objectBoolean, stringBoolean]

// Do an xor to the array
def result = bools.xor()

// Assert that the result is true
assert result == true