Class Booleans
- java.lang.Object
-
- org.openl.rules.util.Booleans
-
public final class Booleans extends Object
A set of util methods to work with booleans.and(Boolean[])andor(Boolean[])methods also handle null values:- null & null = null
- null & true = null
- null & false = false
- null | null = null
- null | true = true
- null | false = null
- Author:
- Yury Molchan
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanallFalse(boolean[] values)static booleanallFalse(Boolean... values)static booleanallNo(boolean[] values)static booleanallNo(Boolean... values)static booleanallTrue(boolean[] values)static booleanallTrue(Boolean... values)static booleanallYes(boolean[] values)static booleanallYes(Boolean... values)static booleananyFalse(boolean[] values)static booleananyFalse(Boolean... values)static booleananyNo(boolean[] values)static booleananyNo(Boolean... values)static booleananyTrue(boolean[] values)static booleananyTrue(Boolean... values)static booleananyYes(boolean[] values)static booleananyYes(Boolean... values)static BooleantoBoolean(byte b)static BooleantoBoolean(char ch)static BooleantoBoolean(int i)static BooleantoBoolean(long l)static BooleantoBoolean(short s)static BooleantoBoolean(Byte b)Converts a byte number to a Boolean.static BooleantoBoolean(Character ch)Converts a Character to a Boolean.static BooleantoBoolean(Integer i)Converts a int number to a Boolean.static BooleantoBoolean(Long l)Converts a long number to a Boolean.static BooleantoBoolean(Short s)Converts a short number to a Boolean.static BooleantoBoolean(String str)Converts a String to a Boolean.static BooleantoBoolean(BigInteger i)Converts a BigInteger to a Boolean.
-
-
-
Method Detail
-
allTrue
public static boolean allTrue(boolean[] values)
-
allTrue
public static boolean allTrue(Boolean... values)
-
anyTrue
public static boolean anyTrue(boolean[] values)
-
anyTrue
public static boolean anyTrue(Boolean... values)
-
allFalse
public static boolean allFalse(boolean[] values)
-
allFalse
public static boolean allFalse(Boolean... values)
-
anyFalse
public static boolean anyFalse(boolean[] values)
-
anyFalse
public static boolean anyFalse(Boolean... values)
-
allYes
public static boolean allYes(boolean[] values)
-
allYes
public static boolean allYes(Boolean... values)
-
allNo
public static boolean allNo(boolean[] values)
-
allNo
public static boolean allNo(Boolean... values)
-
anyYes
public static boolean anyYes(boolean[] values)
-
anyYes
public static boolean anyYes(Boolean... values)
-
anyNo
public static boolean anyNo(boolean[] values)
-
anyNo
public static boolean anyNo(Boolean... values)
-
toBoolean
public static Boolean toBoolean(Character ch)
Converts a Character to a Boolean.
'1','y'or'Y'will returntrue.'0','n'or'N'will returnfalse. Otherwise,nullis returned.toBoolean('0') = Boolean.FALSE toBoolean('1') = Boolean.TRUE toBoolean('y') = Boolean.TRUE // i.e. Y toBoolean('n') = Boolean.FALSE // i.e. N toBoolean(null) = null- Parameters:
ch- the Character to check- Returns:
- the Boolean value of the Character,
nullif no match ornullinput
-
toBoolean
public static Boolean toBoolean(char ch)
-
toBoolean
public static Boolean toBoolean(BigInteger i)
Converts a BigInteger to a Boolean.
'1'will returntrue.'0'will returnfalse. Otherwise,nullis returned.toBoolean(new BigInteger("0")) = Boolean.FALSE toBoolean(new BigInteger("1")) = Boolean.TRUE toBoolean(null) = null- Parameters:
i- the BigInteger to check- Returns:
- the Boolean value of the BigInteger,
nullif no match ornullinput
-
toBoolean
public static Boolean toBoolean(Byte b)
Converts a byte number to a Boolean.
'1'will returntrue.'0'will returnfalse. Otherwise,nullis returned.toBoolean((byte) 0) = Boolean.FALSE toBoolean((byte) 1) = Boolean.TRUE toBoolean((byte) 10) = null toBoolean(null) = null
- Parameters:
b- the byte number to check- Returns:
- the Boolean value of the byte number,
nullif no match ornullinput
-
toBoolean
public static Boolean toBoolean(byte b)
-
toBoolean
public static Boolean toBoolean(Short s)
Converts a short number to a Boolean.
1will returntrue.0will returnfalse. Otherwise,nullis returned.toBoolean((short) 0) = Boolean.FALSE toBoolean((short) 1) = Boolean.TRUE toBoolean((short) 10) = null toBoolean(null) = null
- Parameters:
s- the short number to check- Returns:
- the Boolean value of the short number,
nullif no match ornullinput
-
toBoolean
public static Boolean toBoolean(short s)
-
toBoolean
public static Boolean toBoolean(Integer i)
Converts a int number to a Boolean.
1will returntrue.0will returnfalse. Otherwise,nullis returned.toBoolean(0) = Boolean.FALSE toBoolean(1) = Boolean.TRUE toBoolean(10) = null toBoolean(null) = null
- Parameters:
i- the int number to check- Returns:
- the Boolean value of the int number,
nullif no match ornullinput
-
toBoolean
public static Boolean toBoolean(int i)
-
toBoolean
public static Boolean toBoolean(Long l)
Converts a long number to a Boolean.
1will returntrue.0will returnfalse. Otherwise,nullis returned.toBoolean(0L) = Boolean.FALSE toBoolean(1L) = Boolean.TRUE toBoolean(10L) = null toBoolean(null) = null
- Parameters:
l- the long number to check- Returns:
- the Boolean value of the long number,
nullif no match ornullinput
-
toBoolean
public static Boolean toBoolean(long l)
-
toBoolean
public static Boolean toBoolean(String str)
Converts a String to a Boolean.
'true','on','y','t'or'yes'(case insensitive) or'1'will returntrue.
'false','off','n','f'or'no'(case insensitive) or'0'will returnfalse. Otherwise,nullis returned.// N.B. case is not significant toBoolean(null) = null toBoolean("true") = Boolean.TRUE toBoolean("0") = Boolean.FALSE toBoolean("1") = Boolean.TRUE toBoolean("T") = Boolean.TRUE // i.e. T[RUE] toBoolean("false") = Boolean.FALSE toBoolean("f") = Boolean.FALSE // i.e. f[alse] toBoolean("No") = Boolean.FALSE toBoolean("n") = Boolean.FALSE // i.e. n[o] toBoolean("on") = Boolean.TRUE toBoolean("ON") = Boolean.TRUE toBoolean("off") = Boolean.FALSE toBoolean("oFf") = Boolean.FALSE toBoolean("yes") = Boolean.TRUE toBoolean("Y") = Boolean.TRUE // i.e. Y[ES] toBoolean("blue") = null toBoolean("true ") = null // trailing space (too long) toBoolean("ono") = null // does not match on or no- Parameters:
str- the String to check; upper and lower case are treated as the same- Returns:
- the Boolean value of the string,
nullif no match ornullinput
-
-