public static final class LazyHeaders.Builder extends Object
LazyHeaderFactory
that will be used to construct a value for the given
key* lazily on a background thread.
This class is not thread safe.
This class may include default values for User-Agent and Accept-Encoding headers. These
will be replaced by calls to either setHeader(String, LazyHeaderFactory)
or
addHeader(String, String)
, even though addHeader(String, LazyHeaderFactory)
would usually append an additional value.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
LazyHeaders.Builder |
addHeader(String key,
LazyHeaderFactory factory)
Adds an
LazyHeaderFactory that will be used to construct a value for the given
key lazily on a background thread. |
LazyHeaders.Builder |
addHeader(String key,
String value)
Adds a value for the given header and returns this builder.
|
LazyHeaders |
build()
Returns a new immutable
LazyHeaders object. |
LazyHeaders.Builder |
setHeader(String key,
LazyHeaderFactory factory)
Replaces all existing
LazyHeaderFactorys for the given key
with the given LazyHeaderFactory . |
LazyHeaders.Builder |
setHeader(String key,
String value)
Replaces all existing
LazyHeaderFactorys for the given key
with the given LazyHeaderFactory . |
public LazyHeaders.Builder addHeader(String key, String value)
Use addHeader(String, LazyHeaderFactory)
if obtaining the value requires I/O
(i.e. an OAuth token).
addHeader(String, LazyHeaderFactory)
public LazyHeaders.Builder addHeader(String key, LazyHeaderFactory factory)
LazyHeaderFactory
that will be used to construct a value for the given
key lazily on a background thread.
Headers may have multiple values whose order is defined by the order in which this method is called.
This class does not prevent you from adding the same value to a given key multiple times
public LazyHeaders.Builder setHeader(String key, String value)
LazyHeaderFactorys
for the given key
with the given LazyHeaderFactory
.
If the given value is null
, the header at the given key will be removed.
Use setHeader(String, LazyHeaderFactory)
if obtaining the value requires I/O
(i.e. an OAuth token).
public LazyHeaders.Builder setHeader(String key, LazyHeaderFactory factory)
LazyHeaderFactorys
for the given key
with the given LazyHeaderFactory
.
If the given value is null
, the header at the given key will be removed.
public LazyHeaders build()
LazyHeaders
object.