Class HttpLongPart

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

public class HttpLongPart extends HttpPartBean
An HttpPart whose value is a long integer.

Mirrors the semantics of BasicLongPart from juneau-rest-common-classic without the Apache HttpCore dependency.

Since:
10.0.0
  • Constructor Details

    • HttpLongPart

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

      public HttpLongPart(String name, Long value)
      Constructor accepting a Long value.
      Parameters:
      name - The part name. Must not be null.
      value - The long value. May be null.
    • HttpLongPart

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

    • of

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

      public static HttpLongPart ofString(String name, String value)
      Creates an HttpLongPart by parsing the given wire 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 HttpLongPart ofLazy(String name, Supplier<Long> supplier)
      Creates an HttpLongPart with a lazy long supplier.
      Parameters:
      name - The part name. Must not be null.
      supplier - Supplier for the long value. Must not be null.
      Returns:
      A new instance. Never null.
    • asLong

      public Optional<Long> asLong()
      Returns the value as an Optional<Long>.
      Returns:
      The long value, wrapped in an Optional. Never null.
    • orElse

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

      public Long toLong()
      Returns the value as a Long, or null if not set.
      Returns:
      The long value, possibly null.