Package io.cui.tools.base
Class BooleanOperations
- java.lang.Object
-
- io.cui.tools.base.BooleanOperations
-
public final class BooleanOperations extends Object
Utility Class providing some boolean operations. In essence, it simplifies 'or' and 'and' operations. Some examples from the unit-tests:@Test void shouldDetectAnyTrue() { assertTrue(BooleanOperations.isAnyTrue(true)); assertTrue(BooleanOperations.isAnyTrue(true, true)); assertTrue(BooleanOperations.isAnyTrue(true, false)); assertFalse(BooleanOperations.isAnyTrue(false, false)); // Not really sensible, but defined contract -> Corner Case assertFalse(BooleanOperations.isAnyTrue()); assertFalse(BooleanOperations.isAnyTrue(null)); } @Test void shouldDetectAnyFalse() { assertFalse(BooleanOperations.isAnyFalse(true)); assertTrue(BooleanOperations.isAnyFalse(true, false)); assertTrue(BooleanOperations.isAnyFalse(false, false)); // Not really sensible, but defined contract -> Corner Case assertFalse(BooleanOperations.isAnyFalse()); assertFalse(BooleanOperations.isAnyFalse(null)); } @Test void shouldDetectAllFalse() { assertFalse(BooleanOperations.areAllFalse(true)); assertFalse(BooleanOperations.areAllFalse(true, false)); assertFalse(BooleanOperations.areAllFalse(true, true)); assertTrue(BooleanOperations.areAllFalse(false, false)); // Not really sensible, but defined contract -> Corner Case assertFalse(BooleanOperations.areAllFalse()); assertFalse(BooleanOperations.areAllFalse(null)); } @Test void shouldDetectAllTrue() { assertTrue(BooleanOperations.areAllTrue(true)); assertFalse(BooleanOperations.areAllTrue(true, false)); assertTrue(BooleanOperations.areAllTrue(true, true)); assertFalse(BooleanOperations.areAllTrue(false, false)); // Not really sensible, but defined contract -> Corner Case assertTrue(BooleanOperations.areAllTrue()); assertTrue(BooleanOperations.areAllTrue(null)); }- Author:
- Eugen Fischer, Oliver Wolff
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanareAllFalse(boolean... parameter)Shorthand for checking if all given booleans arefalsestatic booleanareAllTrue(boolean... parameter)Shorthand for checking if all the given booleans aretruestatic booleanisAnyFalse(boolean... parameter)Shorthand for checking if at least one of the given booleans isfalsestatic booleanisAnyTrue(boolean... parameter)Shorthand for checking if at least one of the given booleans istruestatic booleanisValidBoolean(String value)
-
-
-
Method Detail
-
isAnyTrue
public static boolean isAnyTrue(boolean... parameter)
Shorthand for checking if at least one of the given booleans istrue- Parameters:
parameter- ellipsis of boolean values- Returns:
trueif one of parameters istrue,falseotherwise
-
areAllTrue
public static boolean areAllTrue(boolean... parameter)
Shorthand for checking if all the given booleans aretrue- Parameters:
parameter- ellipsis of boolean values- Returns:
trueif all parameters aretrueor no parameter is given ratio: no given false,falseotherwise
-
areAllFalse
public static boolean areAllFalse(boolean... parameter)
Shorthand for checking if all given booleans arefalse- Parameters:
parameter- ellipsis of boolean values- Returns:
trueif all parameters arefalse,trueotherwise.falseif no parameter is passed, ratio: no given false
-
isAnyFalse
public static boolean isAnyFalse(boolean... parameter)
Shorthand for checking if at least one of the given booleans isfalse- Parameters:
parameter- ellipsis of boolean values- Returns:
trueif one of parameters isfalse,trueotherwise
-
isValidBoolean
public static boolean isValidBoolean(String value)
- Parameters:
value- to be checked- Returns:
- true, if the given value represents a boolean value i.e. "true" or "false" ignoring case.
-
-