Class HttpLongHeader

java.lang.Object
org.apache.juneau.http.header.HttpHeaderBean
org.apache.juneau.http.header.HttpLongHeader
All Implemented Interfaces:
HttpHeader
Direct Known Subclasses:
ContentLength

public class HttpLongHeader extends HttpHeaderBean
Base for long headers.
Since:
9.2.1
  • Field Details

  • Constructor Details

    • HttpLongHeader

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

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

      protected HttpLongHeader(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_LONG.
  • Method Details

    • of

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

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

      public Optional<Long> asLong()
    • 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.
    • orElse

      public Long orElse(Long other)
      Returns the parsed value of this header, or the specified default if unset.
      Parameters:
      other - The default value. Can be null.
      Returns:
      The parsed value, or other if the value is unset. Can be null if other is null.
    • toLong

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