Package org.apache.juneau.http.part
Class HttpLongPart
java.lang.Object
org.apache.juneau.http.part.HttpPartBean
org.apache.juneau.http.part.HttpLongPart
- All Implemented Interfaces:
HttpPart
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 Summary
ConstructorsConstructorDescriptionHttpLongPart(String name, Long value) Constructor accepting aLongvalue.HttpLongPart(String name, String value) Constructor accepting a wire-format string value.HttpLongPart(String name, Supplier<Long> supplier) Constructor accepting a lazyLongsupplier. -
Method Summary
Modifier and TypeMethodDescriptionasLong()Returns the value as anOptional<Long>.static HttpLongPartCreates anHttpLongPartwith the given name and long value.static HttpLongPartCreates anHttpLongPartwith a lazy long supplier.static HttpLongPartCreates anHttpLongPartby parsing the given wire value.Returns the value if present, otherwise returnsother.toLong()Returns the value as aLong, ornullif not set.
-
Constructor Details
-
HttpLongPart
Constructor accepting a wire-format string value.- Parameters:
name- The part name. Must not benull .value- The wire value. May benull or empty.
-
HttpLongPart
Constructor accepting aLongvalue.- Parameters:
name- The part name. Must not benull .value- The long value. May benull .
-
HttpLongPart
Constructor accepting a lazyLongsupplier.- Parameters:
name- The part name. Must not benull .supplier- Supplier for the long value. Must not benull .
-
-
Method Details
-
of
Creates anHttpLongPartwith the given name and long value.- Parameters:
name- The part name. Must not benull .value- The long value. May benull .- Returns:
- A new instance. Never
null .
-
ofString
Creates anHttpLongPartby parsing the given wire value.- Parameters:
name- The part name. Must not benull .value- The wire value. May benull or empty.- Returns:
- A new instance. Never
null .
-
ofLazy
Creates anHttpLongPartwith a lazy long supplier.- Parameters:
name- The part name. Must not benull .supplier- Supplier for the long value. Must not benull .- Returns:
- A new instance. Never
null .
-
asLong
Returns the value as anOptional<Long>.- Returns:
- The long value, wrapped in an
Optional. Nevernull .
-
orElse
Returns the value if present, otherwise returnsother.- Parameters:
other- The default value.- Returns:
- The value or
other.
-
toLong
Returns the value as aLong, ornullif not set.- Returns:
- The long value, possibly
null.
-