Class BasicLongPart

java.lang.Object
org.apache.juneau.http.part.BasicPart
org.apache.juneau.http.part.BasicLongPart
All Implemented Interfaces:
NameValuePair, Headerable

public class BasicLongPart extends BasicPart
A NameValuePair that consists of a single long value.
See Also:
  • Constructor Details

    • BasicLongPart

      public BasicLongPart(String name, Long value)
      Constructor.
      Parameters:
      name - The part name. Must not be null.
      value - The part value. Can be null.
    • BasicLongPart

      public BasicLongPart(String name, Supplier<Long> value)
      Constructor.
      Parameters:
      name - The part name. Must not be null.
      value - The part value supplier. Can be null or supply null.
    • BasicLongPart

      public BasicLongPart(String name, String value)
      Constructor.

      null and empty values are treated as null. Otherwise parses using Long.valueOf(String).

      Parameters:
      name - The part name. Must not be null.
      value - The part value. Can be null.
  • Method Details

    • of

      public static BasicLongPart of(String name, Long value)
      Static creator.
      Parameters:
      name - The part name.
      value - The part value.
      Returns:
      A new BasicLongPart object, or null if the name or value is null.
    • of

      public static BasicLongPart of(String name, Supplier<Long> value)
      Static creator with delayed value.

      Part value is re-evaluated on each call to NameValuePair.getValue().

      Parameters:
      name - The part name.
      value - The part value supplier.
      Returns:
      A new BasicLongPart object, or null if the name or supplier is null.
    • getValue

      public String getValue()
      Specified by:
      getValue in interface NameValuePair
      Overrides:
      getValue in class BasicPart
    • asLong

      public Optional<Long> asLong()
      Returns The part value as a Long wrapped in an Optional.
      Returns:
      The part value as a Long wrapped in an Optional. Never null.
    • toLong

      public Long toLong()
      Returns The part value as a Long.
      Returns:
      The part value as a Long, or null if the value null.
    • assertLong

      Provides the ability to perform fluent-style assertions on this part.
      Returns:
      A new fluent assertion object.
      Throws:
      AssertionError - If assertion failed.
    • orElse

      public Long orElse(Long other)
      Return the value if present, otherwise return other.

      This is a shortened form for calling asLong().orElse(other).

      Parameters:
      other - The value to be returned if there is no value present, can be null.
      Returns:
      The value, if present, otherwise other.