Class HttpBooleanHeader

java.lang.Object
org.apache.juneau.http.header.HttpHeaderBean
org.apache.juneau.http.header.HttpBooleanHeader
All Implemented Interfaces:
HttpHeader
Direct Known Subclasses:
Debug, NoTrace

public class HttpBooleanHeader extends HttpHeaderBean
Base for boolean headers.
Since:
9.2.1
  • Field Details

  • Constructor Details

    • HttpBooleanHeader

      protected HttpBooleanHeader(String name, String wireValue)
      Constructor.
      Parameters:
      name - Header name. Must not be null.
      wireValue - Wire value (e.g. "true"). Can be null or empty, in which case the parsed value is null.
    • HttpBooleanHeader

      protected HttpBooleanHeader(String name, Boolean typedValue)
      Constructor.
      Parameters:
      name - Header name. Must not be null.
      typedValue - The boolean value. Can be null, in which case the parsed value is null.
    • HttpBooleanHeader

      protected HttpBooleanHeader(String name, Supplier<?> supplier, int lazyMode)
      Constructor with lazy value supplier.
      Parameters:
      name - Header name. Must not be null.
      supplier - The lazy value supplier. Must not be null.
      lazyMode - Either LAZY_WIRE_STRING or LAZY_BOOLEAN.
  • Method Details

    • of

      public static HttpBooleanHeader of(String name, String wireValue)
      Creates an HttpBooleanHeader by parsing the given wire-format value.
      Parameters:
      name - Header name. Must not be null.
      wireValue - Wire value (e.g. "true"). May be null.
      Returns:
      A new instance. Never null.
    • of

      public static HttpBooleanHeader of(String name, Boolean typedValue)
      Creates an HttpBooleanHeader with the given typed value.
      Parameters:
      name - Header name. Must not be null.
      typedValue - The boolean value. May be null.
      Returns:
      A new instance. Never null.
    • asBoolean

    • getValue

      public String getValue()
      Returns the wire-format value of this header.
      Specified by:
      getValue in interface HttpHeader
      Overrides:
      getValue in class HttpHeaderBean
      Returns:
      The wire value, or null if the value is unset.
    • isTrue

      public boolean isTrue()
      Returns true if the parsed value is true.
      Returns:
      true if the parsed value is true; false if it is false or unset.
    • orElse

      public Boolean orElse(Boolean other)
      Returns the parsed value of this header, or the specified default if unset.
      Parameters:
      other - The default value. Can be null to allow a null result when the header is unset.
      Returns:
      The parsed value, or other if the value is unset. Can be null if other is null.
    • toBoolean

      public Boolean toBoolean()
      Returns the parsed value of this header.
      Returns:
      The parsed value, or null if the value is unset.