Package cn.sliew.milky.common.primitives
Class Booleans
- java.lang.Object
-
- cn.sliew.milky.common.primitives.Booleans
-
public final class Booleans extends Object
Static utility methods pertaining tobooleanprimitives.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisBoolean(char[] text, int offset, int length)returns true iff the sequence of chars is one of "true","false".static booleanisBoolean(String value)static booleanisFalse(String value)static booleanisTrue(String value)static booleanparseBoolean(char[] text, int offset, int length, boolean defaultValue)Parses a char[] representation of a boolean value toboolean.static booleanparseBoolean(String value)Parses a string representation of a boolean value toboolean.static booleanparseBoolean(String value, boolean defaultValue)static BooleanparseBoolean(String value, Boolean defaultValue)
-
-
-
Field Detail
-
TRUE
public static final String TRUE
- See Also:
- Constant Field Values
-
FALSE
public static final String FALSE
- See Also:
- Constant Field Values
-
-
Method Detail
-
isBoolean
public static boolean isBoolean(char[] text, int offset, int length)returns true iff the sequence of chars is one of "true","false".- Parameters:
text- sequence to checkoffset- offset to startlength- length to check
-
isBoolean
public static boolean isBoolean(String value)
-
isFalse
public static boolean isFalse(String value)
- Returns:
trueiff the value is "false", otherwisefalse.
-
isTrue
public static boolean isTrue(String value)
- Returns:
trueiff the value is "true", otherwisefalse.
-
parseBoolean
public static boolean parseBoolean(char[] text, int offset, int length, boolean defaultValue)Parses a char[] representation of a boolean value toboolean.- Returns:
trueiff the sequence of chars is "true",falseiff the sequence of chars is "false" or the provided default value iff either text isnullor length == 0.- Throws:
IllegalArgumentException- if the string cannot be parsed to boolean.
-
parseBoolean
public static boolean parseBoolean(String value)
Parses a string representation of a boolean value toboolean.- Returns:
trueiff the provided value is "true".falseiff the provided value is "false".- Throws:
IllegalArgumentException- if the string cannot be parsed to boolean.
-
parseBoolean
public static boolean parseBoolean(String value, boolean defaultValue)
- Parameters:
value- text to parse.defaultValue- The default value to return if the provided value isnull.- Returns:
- see
parseBoolean(String)
-
-