Package org.opensearch.common
Class Booleans
java.lang.Object
org.opensearch.common.Booleans
Extended Boolean functionality
- Opensearch.internal:
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisBoolean(char[] text, int offset, int length) Returns true iff the sequence of chars is one of "true", "false".static booleanstatic booleanstatic booleanstatic 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) Deprecated.static BooleanparseBoolean(String value, Boolean defaultValue) Deprecated.static booleanparseBooleanStrict(String value, boolean defaultValue) Parses a string representation of a boolean value toboolean.
-
Method Details
-
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.
-
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
-
parseBoolean
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
Deprecated.Parses a string representation of a boolean value toboolean. Note the subtle difference between this andparseBoolean(char[], int, int, boolean); this returns the default value even when the value is non-zero length containing all whitespaces (possibly overlooked, but preserving this behavior for compatibility reasons). UseparseBooleanStrict(String, boolean)instead.- Parameters:
value- text to parse.defaultValue- The default value to return if the provided value isnullor blank.- Returns:
- see
parseBoolean(String)
-
parseBoolean
Deprecated. -
parseBooleanStrict
Parses a string representation of a boolean value toboolean. Analogous toparseBoolean(char[], int, int, boolean).- 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.
-
isFalse
- Returns:
trueiff the value is "false", otherwisefalse.
-
isTrue
- Returns:
trueiff the value is "true", otherwisefalse.
-