-
public final class LazyHeaders.BuilderAdds an 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 willbe replaced by calls to either setHeader or , even though addHeader wouldusually append an additional value.
-
-
Method Summary
Modifier and Type Method Description LazyHeaders.BuilderaddHeader(@NonNull() String key, @NonNull() String value)Adds a value for the given header and returns this builder. LazyHeaders.BuilderaddHeader(@NonNull() String key, @NonNull() LazyHeaderFactory factory)Adds an LazyHeaderFactory that will be used to construct a value for the given keylazily on a background thread. LazyHeaders.BuildersetHeader(@NonNull() String key, @Nullable() String value)Replaces all existing LazyHeaderFactorys for the given key with thegiven LazyHeaderFactory. LazyHeaders.BuildersetHeader(@NonNull() String key, @Nullable() LazyHeaderFactory factory)Replaces all existing LazyHeaderFactorys for the given key with thegiven LazyHeaderFactory. LazyHeadersbuild()Returns a new immutable LazyHeaders object. -
-
Method Detail
-
addHeader
LazyHeaders.Builder addHeader(@NonNull() String key, @NonNull() String value)
Adds a value for the given header and returns this builder.
Use addHeader if obtaining the value requires I/O(i.e. an OAuth token).
-
addHeader
LazyHeaders.Builder addHeader(@NonNull() String key, @NonNull() LazyHeaderFactory factory)
Adds an LazyHeaderFactory that will be used to construct a value for the given keylazily on a background thread.
Headers may have multiple values whose order is defined by the order in which this methodis called.
This class does not prevent you from adding the same value to a given key multiple times
-
setHeader
LazyHeaders.Builder setHeader(@NonNull() String key, @Nullable() String value)
Replaces all existing LazyHeaderFactorys for the given key with thegiven LazyHeaderFactory.
If the given value is
{@code null}, the header at the given key will be removed.Use setHeader if obtaining the value requires I/O(i.e. an OAuth token).
-
setHeader
LazyHeaders.Builder setHeader(@NonNull() String key, @Nullable() LazyHeaderFactory factory)
Replaces all existing LazyHeaderFactorys for the given key with thegiven LazyHeaderFactory.
If the given value is
{@code null}, the header at the given key will be removed.
-
build
LazyHeaders build()
Returns a new immutable LazyHeaders object.
-
-
-
-