Package org.apache.juneau.http.part
Class HttpIntegerPart
java.lang.Object
org.apache.juneau.http.part.HttpPartBean
org.apache.juneau.http.part.HttpIntegerPart
- All Implemented Interfaces:
HttpPart
An
HttpPart whose value is an integer.
Mirrors the semantics of BasicIntegerPart from juneau-rest-common-classic without
the Apache HttpCore dependency.
- Since:
- 10.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionHttpIntegerPart(String name, Integer value) Constructor accepting anIntegervalue.HttpIntegerPart(String name, String value) Constructor accepting a wire-format string value.HttpIntegerPart(String name, Supplier<Integer> supplier) Constructor accepting a lazyIntegersupplier. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value as anOptional<Integer>.static HttpIntegerPartCreates anHttpIntegerPartwith the given name and integer value.static HttpIntegerPartCreates anHttpIntegerPartwith a lazy integer supplier.static HttpIntegerPartCreates anHttpIntegerPartby parsing the given wire value.Returns the value if present, otherwise returnsother.Returns the value as anInteger, ornullif not set.
-
Constructor Details
-
HttpIntegerPart
Constructor accepting a wire-format string value.- Parameters:
name- The part name. Must not benull .value- The wire value. May benull or empty.
-
HttpIntegerPart
Constructor accepting anIntegervalue.- Parameters:
name- The part name. Must not benull .value- The integer value. May benull .
-
HttpIntegerPart
Constructor accepting a lazyIntegersupplier.- Parameters:
name- The part name. Must not benull .supplier- Supplier for the integer value. Must not benull .
-
-
Method Details
-
of
Creates anHttpIntegerPartwith the given name and integer value.- Parameters:
name- The part name. Must not benull .value- The integer value. May benull .- Returns:
- A new instance. Never
null .
-
ofString
Creates anHttpIntegerPartby 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 anHttpIntegerPartwith a lazy integer supplier.- Parameters:
name- The part name. Must not benull .supplier- Supplier for the integer value. Must not benull .- Returns:
- A new instance. Never
null .
-
asInteger
Returns the value as anOptional<Integer>.- Returns:
- The integer value, wrapped in an
Optional. Nevernull .
-
orElse
Returns the value if present, otherwise returnsother.- Parameters:
other- The default value.- Returns:
- The value or
other.
-
toInteger
Returns the value as anInteger, ornullif not set.- Returns:
- The integer value, possibly
null.
-