Package io.datareplication.model
Class HttpHeaders
- java.lang.Object
-
- io.datareplication.model.HttpHeaders
-
- All Implemented Interfaces:
ToHttpHeaders,java.lang.Iterable<@NonNull HttpHeader>
public final class HttpHeaders extends java.lang.Object implements java.lang.Iterable<@NonNull HttpHeader>, ToHttpHeaders
A collection of multipleHttpHeaderobjects. There's only one set of values per name so repeated headers must be merged into a singleHttpHeaderwith multiple values. The iteration order of headers is not guaranteed and the order is not preserved.
-
-
Field Summary
Fields Modifier and Type Field Description static @NonNull HttpHeadersEMPTYAn empty HttpHeaders instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)@NonNull java.util.Optional<@NonNull HttpHeader>get(@NonNull java.lang.String key)inthashCode()booleanisEmpty()@NonNull java.util.Iterator<@NonNull HttpHeader>iterator()Iterate over the headers in this object.static @NonNull HttpHeadersof(@NonNull HttpHeader... headers)Create a new HttpHeaders from the given headers.static @NonNull HttpHeadersof(@NonNull java.lang.Iterable<@NonNull HttpHeader> headers)Create a new HttpHeaders from the given headers.static @NonNull HttpHeadersof(@NonNull java.util.Iterator<@NonNull HttpHeader> headers)Create a new HttpHeaders from the given headers.@NonNull java.util.stream.Stream<@NonNull HttpHeader>stream()Return aStreamover the headers in this object.@NonNull HttpHeaderstoHttpHeaders()Return HTTP headers for this object.java.lang.StringtoString()@NonNull HttpHeadersupdate(@NonNull HttpHeader... headers)Return a new HttpHeaders with the given headers updated.@NonNull HttpHeadersupdate(@NonNull java.lang.Iterable<@NonNull HttpHeader> headers)Return a new HttpHeaders with the given headers updated.@NonNull HttpHeadersupdate(@NonNull java.util.Iterator<@NonNull HttpHeader> headers)Return a new HttpHeaders with the given headers updated.
-
-
-
Field Detail
-
EMPTY
@NonNull public static final @NonNull HttpHeaders EMPTY
An empty HttpHeaders instance.
-
-
Method Detail
-
iterator
@NonNull public @NonNull java.util.Iterator<@NonNull HttpHeader> iterator()
Iterate over the headers in this object. Iteration order is arbitrary and not guaranteed to be consistent.- Specified by:
iteratorin interfacejava.lang.Iterable<@NonNull HttpHeader>- Returns:
- an iterator over all
HttpHeadervalues in this collection
-
stream
@NonNull public @NonNull java.util.stream.Stream<@NonNull HttpHeader> stream()
Return aStreamover the headers in this object.- Returns:
- a
Streamover allHttpHeadervalues in this collection
-
update
@NonNull public @NonNull HttpHeaders update(@NonNull @NonNull HttpHeader... headers)
Return a new HttpHeaders with the given headers updated. Any header names that are already present will be replaced, i.e. values are not merged.- Parameters:
headers- the headers to update- Returns:
- a new HttpHeaders with the given updates
-
update
@NonNull public @NonNull HttpHeaders update(@NonNull @NonNull java.lang.Iterable<@NonNull HttpHeader> headers)
Return a new HttpHeaders with the given headers updated. Any header names that are already present will be replaced, i.e. values are not merged.- Parameters:
headers- the headers to update- Returns:
- a new HttpHeaders with the given updates
-
update
@NonNull public @NonNull HttpHeaders update(@NonNull @NonNull java.util.Iterator<@NonNull HttpHeader> headers)
Return a new HttpHeaders with the given headers updated. Any header names that are already present will be replaced, i.e. values are not merged.- Parameters:
headers- the headers to update- Returns:
- a new HttpHeaders with the given updates
-
isEmpty
public boolean isEmpty()
- Returns:
- Check if this HttpHeaders is empty.
-
toHttpHeaders
@NonNull public @NonNull HttpHeaders toHttpHeaders()
Description copied from interface:ToHttpHeadersReturn HTTP headers for this object.- Specified by:
toHttpHeadersin interfaceToHttpHeaders- Returns:
- HTTP headers associated with this object
-
get
@NonNull public @NonNull java.util.Optional<@NonNull HttpHeader> get(@NonNull @NonNull java.lang.String key)
-
of
@NonNull public static @NonNull HttpHeaders of(@NonNull @NonNull HttpHeader... headers)
Create a new HttpHeaders from the given headers. Only the last value for any given header name will be kept.- Parameters:
headers- the headers to include- Returns:
- a new HttpHeaders from the given headers.
-
of
@NonNull public static @NonNull HttpHeaders of(@NonNull @NonNull java.lang.Iterable<@NonNull HttpHeader> headers)
Create a new HttpHeaders from the given headers. Only the last value for any given header name will be kept.- Parameters:
headers- the headers to include- Returns:
- a new HttpHeaders from the given headers.
-
of
@NonNull public static @NonNull HttpHeaders of(@NonNull @NonNull java.util.Iterator<@NonNull HttpHeader> headers)
Create a new HttpHeaders from the given headers. Only the last value for any given header name will be kept.- Parameters:
headers- the headers to include- Returns:
- the HttpHeaders
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-