BooleanMethods
The BooleanMethods
class contains one-liners
for handling boolean
primitives and Boolean
objects in Gloop.
Recommended for use in Gloop only
In Groovy, you can use methods from the
org.apache.commons.lang3.BooleanUtils
class instead
for your boolean-operation needs. BooleanMethods
extends this class but adds a few more methods.
Their contents are more or less the same.
You can use these methods in both Gloop and Groovy. Below is a snippet showing how
to use BooleanMethods
's instance extension methods:
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 |