Package org.apache.juneau.http.part
Class HttpStringPart
java.lang.Object
org.apache.juneau.http.part.HttpPartBean
org.apache.juneau.http.part.HttpStringPart
- All Implemented Interfaces:
HttpPart
An
HttpPart whose value is a string.
Mirrors the semantics of BasicStringPart from juneau-rest-common-classic without
the Apache HttpCore dependency.
- Since:
- 10.0.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHttpStringPart(String name, String value) Constructor.protectedHttpStringPart(String name, Supplier<String> valueSupplier) Constructor with lazy value supplier. -
Method Summary
Modifier and TypeMethodDescriptionasString()Returns the value as anOptional.static HttpStringPartCreates anHttpStringPartwith the given name and string value.static HttpStringPartCreates anHttpStringPartwith the given name and lazy value supplier.static HttpStringPartReturns the value if present, otherwise returnsother.
-
Constructor Details
-
HttpStringPart
Constructor.- Parameters:
name- The part name. Must not benull .value- The part value. May benull .
-
HttpStringPart
Constructor with lazy value supplier.- Parameters:
name- The part name. Must not benull .valueSupplier- Supplier that provides the value at request time. Must not benull .
-
-
Method Details
-
of
Creates anHttpStringPartwith the given name and string value.- Parameters:
name- The part name. Must not benull .value- The part value. May benull .- Returns:
- A new instance. Never
null .
-
of
Creates anHttpStringPartwith the given name and lazy value supplier.- Parameters:
name- The part name. Must not benull .valueSupplier- Supplier for the value. Must not benull .- Returns:
- A new instance. Never
null .
-
ofPair
Parses a part pair of the form"name=value"(or"name:value") into anHttpStringPart.If the input does not contain
'='or':', the entire string is treated as a part name with an empty value.- Parameters:
pair- The part pair. May benull.- Returns:
- A new instance, or
nullifpairisnull.
-
asString
Returns the value as anOptional.- Returns:
- The value, wrapped in an
Optional. Nevernull .
-
orElse
Returns the value if present, otherwise returnsother.- Parameters:
other- The default value.- Returns:
- The value or
other.
-