Class Booleans

java.lang.Object
org.opensearch.common.Booleans

public final class Booleans extends Object
Extended Boolean functionality
Opensearch.internal:
  • Method Details

    • parseBoolean

      public static boolean parseBoolean(char[] text, int offset, int length, boolean defaultValue)
      Parses a char[] representation of a boolean value to boolean.
      Returns:
      true iff the sequence of chars is "true", false iff the sequence of chars is "false" or the provided default value iff either text is null or 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 check
      offset - offset to start
      length - length to check
    • isBoolean

      public static boolean isBoolean(String value)
    • parseBoolean

      public static boolean parseBoolean(String value)
      Parses a string representation of a boolean value to boolean.
      Returns:
      true iff the provided value is "true". false iff the provided value is "false".
      Throws:
      IllegalArgumentException - if the string cannot be parsed to boolean.
    • parseBoolean

      @Deprecated public static boolean parseBoolean(String value, boolean defaultValue)
      Deprecated.
      Parses a string representation of a boolean value to boolean. Note the subtle difference between this and parseBoolean(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). Use parseBooleanStrict(String, boolean) instead.
      Parameters:
      value - text to parse.
      defaultValue - The default value to return if the provided value is null or blank.
      Returns:
      see parseBoolean(String)
    • parseBoolean

      @Deprecated public static Boolean parseBoolean(String value, Boolean defaultValue)
      Deprecated.
    • parseBooleanStrict

      public static boolean parseBooleanStrict(String value, boolean defaultValue)
      Parses a string representation of a boolean value to boolean. Analogous to parseBoolean(char[], int, int, boolean).
      Returns:
      true iff the sequence of chars is "true", false iff the sequence of chars is "false", or the provided default value iff either text is null or length == 0.
      Throws:
      IllegalArgumentException - if the string cannot be parsed to boolean.
    • isFalse

      public static boolean isFalse(String value)
      Returns:
      true iff the value is "false", otherwise false.
    • isTrue

      public static boolean isTrue(String value)
      Returns:
      true iff the value is "true", otherwise false.