Class HttpBooleanPart

java.lang.Object
org.apache.juneau.http.part.HttpPartBean
org.apache.juneau.http.part.HttpBooleanPart
All Implemented Interfaces:
HttpPart

public class HttpBooleanPart extends HttpPartBean
An HttpPart whose value is a boolean.

Mirrors the semantics of BasicBooleanPart from juneau-rest-common-classic without the Apache HttpCore dependency. The wire value uses "true" / "false".

Since:
10.0.0
  • Constructor Details

    • HttpBooleanPart

      public HttpBooleanPart(String name, String value)
      Constructor accepting a wire-format string value.
      Parameters:
      name - The part name. Must not be null.
      value - The wire value (e.g. "true"). May be null or empty.
    • HttpBooleanPart

      public HttpBooleanPart(String name, Boolean value)
      Constructor accepting a Boolean value.
      Parameters:
      name - The part name. Must not be null.
      value - The boolean value. May be null.
    • HttpBooleanPart

      public HttpBooleanPart(String name, Supplier<Boolean> supplier)
      Constructor accepting a lazy Boolean supplier.
      Parameters:
      name - The part name. Must not be null.
      supplier - Supplier for the boolean value. Must not be null.
  • Method Details

    • of

      public static HttpBooleanPart of(String name, Boolean value)
      Creates an HttpBooleanPart with the given name and boolean value.
      Parameters:
      name - The part name. Must not be null.
      value - The boolean value. May be null.
      Returns:
      A new instance. Never null.
    • ofString

      public static HttpBooleanPart ofString(String name, String value)
      Creates an HttpBooleanPart by parsing the given string value.
      Parameters:
      name - The part name. Must not be null.
      value - The wire value. May be null or empty.
      Returns:
      A new instance. Never null.
    • ofLazy

      public static HttpBooleanPart ofLazy(String name, Supplier<Boolean> supplier)
      Creates an HttpBooleanPart with a lazy boolean supplier.
      Parameters:
      name - The part name. Must not be null.
      supplier - Supplier for the boolean value. Must not be null.
      Returns:
      A new instance. Never null.
    • asBoolean

      Returns the value as an Optional<Boolean>.
      Returns:
      The boolean value, wrapped in an Optional. Never null.
    • orElse

      public Boolean orElse(Boolean other)
      Returns the value if present, otherwise returns other.
      Parameters:
      other - The default value.
      Returns:
      The value or other.
    • toBoolean

      public Boolean toBoolean()
      Returns the value as a Boolean, or null if not set.
      Returns:
      The boolean value, possibly null.