Package org.apache.juneau.http
Class HttpParts
java.lang.Object
org.apache.juneau.http.HttpParts
Static factory methods for creating HTTP parts (query parameters, form fields, path variables).
Import statically for clean DSL-style usage:
import static HttpParts.*;
PartList
See Also:
- Since:
- 9.2.1
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<ConstructorInfo>getConstructor(ClassMeta<?> type) Returns the(String)or(String,String)public constructor for the specified type.getName(HttpPartType partType, ClassMeta<?> type) Returns the name of the specified part type by reading the@Header,@Query,@FormData, or@Pathannotation on the class.static booleanisHttpPart(HttpPartType partType, ClassMeta<?> type) Returnstrue if the specified type is a transport-neutral part type for the givenHttpPartType.static HttpPartCreates anHttpPartwith an eager string value.static HttpPartCreates anHttpPartwith a lazy value supplier.static PartListCreates aPartListfrom the given parts.static PartListpartListOfPairs(String... pairs) Creates aPartListfrom alternating name/value string pairs.
-
Method Details
-
part
Creates anHttpPartwith an eager string value.- Parameters:
name- The part name. Must not benull .value- The part value. May benull .- Returns:
- A new part. Never
null .
-
part
Creates anHttpPartwith a lazy value supplier.- Parameters:
name- The part name. Must not benull .valueSupplier- Supplier for the value. Must not benull .- Returns:
- A new part. Never
null .
-
partList
Creates aPartListfrom the given parts.- Parameters:
parts- The parts. Must not benull .- Returns:
- A new list. Never
null .
-
partListOfPairs
Creates aPartListfrom alternating name/value string pairs.- Parameters:
pairs- Alternating name/value strings. Must not benull . Length must be even.- Returns:
- A new list. Never
null .
-
getConstructor
Returns the(String)or(String,String)public constructor for the specified type.Used by part-parsing logic to instantiate typed parts from a wire string.
- Parameters:
type- The type to find the constructor on. Must not benull .- Returns:
- The constructor wrapped in an
Optional; empty if none is found.
-
isHttpPart
Returnstrue if the specified type is a transport-neutral part type for the givenHttpPartType.The check is whether the type is assignable to
HttpHeader(forHEADER) orHttpPart(forPATH,QUERY,FORMDATA).- Parameters:
partType- The part type. Must not benull .type- The type to check. Must not benull .- Returns:
true if the type is a part type for the given category.
-
getName
Returns the name of the specified part type by reading the@Header,@Query,@FormData, or@Pathannotation on the class.- Parameters:
partType- The part type. Must not benull .type- The type to check. Must not benull .- Returns:
- The part name, wrapped in an
Optional.
-