Package org.apache.juneau.http.part
Class HttpPartList
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<HttpPart>,Collection<HttpPart>,List<HttpPart>,RandomAccess
- Direct Known Subclasses:
HttpPartList.Unmodifiable,HttpPartList.Void
A mutable, ordered list of
HttpPart instances.
Mirrors the semantics of PartList from juneau-rest-common-classic without the
Apache HttpCore dependency. Part-name comparisons are case-sensitive by default (matching the
classic default for parts; headers use case-insensitive comparisons).
Use PartList when you need an immutable list bound to an HTTP body (e.g.
application/x-www-form-urlencoded); use HttpPartList when you need a mutable
builder for default form data / query parameter lists.
See Also:
- Since:
- 10.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn unmodifiable snapshot of aHttpPartList.static final classRepresents no part list in annotations. -
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor.protectedHttpPartList(HttpPartList copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionAppends a part constructed from the given name and string value.Appends the given parts in order.Appends the given part.Appends the given parts in order.caseInsensitive(boolean value) Sets whether part-name comparisons are case-insensitive.booleanReturnstrueif a part with the given name is present.copy()Returns a copy of this list.static HttpPartListcreate()Creates a new emptyHttpPartList.Performs an action on each part whose name matches.HttpPart[]getAll()Returns all parts in this list as a typed array.Returns all parts with the given name in insertion order.Returns the first part with the given name, ornullif absent.Returns the last part with the given name, ornullif absent.booleanReturnstrue if this list is an unmodifiable snapshot.static HttpPartListCreates a newHttpPartListinitialized with the given parts.static HttpPartListCreates a newHttpPartListinitialized with the given parts.static HttpPartListRemoves all parts with the given name.Sets a part with the given name and value, replacing any prior entry with the same name.Sets the given part, replacing any prior entry with the same name.Sets the given parts, each replacing any prior entry with the same name.setDefault(String name, String value) Sets a default part with the given name and value (first-in-chain wins per name).setDefault(HttpPart value) Sets the given part as a default.setDefault(HttpPart... values) Sets the given parts as defaults, in order.HttpPart[]Returns the parts in this list as a typed array.Returns an unmodifiable snapshot of this list.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll
-
Constructor Details
-
HttpPartList
public HttpPartList()Constructor. -
HttpPartList
Copy constructor.- Parameters:
copyFrom- The list to copy. Must not benull .
-
-
Method Details
-
create
Creates a new emptyHttpPartList.- Returns:
- A new instance. Never
null .
-
of
Creates a newHttpPartListinitialized with the given parts.- Parameters:
parts- The parts to include.nullentries are ignored.- Returns:
- A new instance. Never
null .
-
of
Creates a newHttpPartListinitialized with the given parts.- Parameters:
parts- The parts to include.nullentries are ignored.- Returns:
- A new instance. Never
null .
-
ofPairs
- Parameters:
pairs- Alternating name/value strings. Can benull (treated as empty). Length must be even.- Returns:
- A new instance. Never
null . - Throws:
IllegalArgumentException- If the number of arguments is odd.
-
caseInsensitive
Sets whether part-name comparisons are case-insensitive. Defaults tofalse(case-sensitive).- Parameters:
value- New value.- Returns:
- This object.
-
append
Appends the given part.- Parameters:
value- The part to add.nullis ignored.- Returns:
- This object.
-
append
Appends the given parts in order.- Parameters:
values- The parts to add.nullentries are ignored.- Returns:
- This object.
-
append
Appends the given parts in order.- Parameters:
values- The parts to add.nullentries are ignored.- Returns:
- This object.
-
append
Appends a part constructed from the given name and string value.- Parameters:
name- The part name. Must not benull .value- The part value. Can benull to omit the part from the request.- Returns:
- This object.
-
setDefault
Sets the given part as a default. If a part with the same name already exists, this is a no-op (first-in-chain wins per name).- Parameters:
value- The part to set.nullis ignored.- Returns:
- This object.
-
setDefault
Sets the given parts as defaults, in order. For each, if a part with the same name already exists, the entry is skipped (first-in-chain wins per name).- Parameters:
values- The parts to set.nullentries are ignored.- Returns:
- This object.
-
setDefault
Sets a default part with the given name and value (first-in-chain wins per name).- Parameters:
name- The part name. Must not benull .value- The part value. Can benull to omit the part from the request.- Returns:
- This object.
-
set
Sets the given part, replacing any prior entry with the same name.- Parameters:
value- The part to set.nullis ignored.- Returns:
- This object.
-
set
Sets the given parts, each replacing any prior entry with the same name.- Parameters:
values- The parts to set.nullentries are ignored.- Returns:
- This object.
-
set
Sets a part with the given name and value, replacing any prior entry with the same name.- Parameters:
name- The part name. Must not benull .value- The part value. Can benull to omit the part from the request.- Returns:
- This object.
-
removeAll
Removes all parts with the given name.- Parameters:
name- The part name. Must not benull .- Returns:
- This object.
-
contains
Returnstrueif a part with the given name is present.- Parameters:
name- The part name.- Returns:
trueif present.
-
getFirst
Returns the first part with the given name, ornullif absent.- Parameters:
name- The part name.- Returns:
- The first matching part, or
null.
-
getLast
Returns the last part with the given name, ornullif absent.- Parameters:
name- The part name.- Returns:
- The last matching part, or
null.
-
getAll
Returns all parts with the given name in insertion order.- Parameters:
name- The part name.- Returns:
- A new list of matching parts. Never
null .
-
getAll
Returns all parts in this list as a typed array.- Returns:
- A new array. Never
null .
-
forEach
Performs an action on each part whose name matches.- Parameters:
name- The part name.action- The action.- Returns:
- This object.
-
copy
Returns a copy of this list.- Returns:
- A new copy. Never
null .
-
unmodifiable
Returns an unmodifiable snapshot of this list.Idempotency: if this list is already an
HttpPartList.Unmodifiablesnapshot, it is returned as-is.- Returns:
- An unmodifiable snapshot of this list, or this list if it is already unmodifiable.
-
isUnmodifiable
Returnstrue if this list is an unmodifiable snapshot.- Returns:
true if this list is anUnmodifiableBeansnapshot.
-
toPartArray
Returns the parts in this list as a typed array.- Returns:
- A new array. Never
null .
-