Package org.apache.juneau.http.part
Class HttpBooleanPart
java.lang.Object
org.apache.juneau.http.part.HttpPartBean
org.apache.juneau.http.part.HttpBooleanPart
- All Implemented Interfaces:
HttpPart
An
HttpPart whose value is a boolean.
Mirrors the semantics of BasicBooleanPart from juneau-rest-common-classic without
the Apache HttpCore dependency. The wire value uses "true" / "false".
- Since:
- 10.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionHttpBooleanPart(String name, Boolean value) Constructor accepting aBooleanvalue.HttpBooleanPart(String name, String value) Constructor accepting a wire-format string value.HttpBooleanPart(String name, Supplier<Boolean> supplier) Constructor accepting a lazyBooleansupplier. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value as anOptional<Boolean>.static HttpBooleanPartCreates anHttpBooleanPartwith the given name and boolean value.static HttpBooleanPartCreates anHttpBooleanPartwith a lazy boolean supplier.static HttpBooleanPartCreates anHttpBooleanPartby parsing the given string value.Returns the value if present, otherwise returnsother.Returns the value as aBoolean, ornullif not set.
-
Constructor Details
-
HttpBooleanPart
Constructor accepting a wire-format string value.- Parameters:
name- The part name. Must not benull .value- The wire value (e.g."true"). May benull or empty.
-
HttpBooleanPart
Constructor accepting aBooleanvalue.- Parameters:
name- The part name. Must not benull .value- The boolean value. May benull .
-
HttpBooleanPart
Constructor accepting a lazyBooleansupplier.- Parameters:
name- The part name. Must not benull .supplier- Supplier for the boolean value. Must not benull .
-
-
Method Details
-
of
Creates anHttpBooleanPartwith the given name and boolean value.- Parameters:
name- The part name. Must not benull .value- The boolean value. May benull .- Returns:
- A new instance. Never
null .
-
ofString
Creates anHttpBooleanPartby parsing the given string 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 anHttpBooleanPartwith a lazy boolean supplier.- Parameters:
name- The part name. Must not benull .supplier- Supplier for the boolean value. Must not benull .- Returns:
- A new instance. Never
null .
-
asBoolean
Returns the value as anOptional<Boolean>.- Returns:
- The boolean value, wrapped in an
Optional. Nevernull .
-
orElse
Returns the value if present, otherwise returnsother.- Parameters:
other- The default value.- Returns:
- The value or
other.
-
toBoolean
Returns the value as aBoolean, ornullif not set.- Returns:
- The boolean value, possibly
null.
-