Class LazyHeaders.Builder
- Enclosing class:
- LazyHeaders
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddHeader(String key, LazyHeaderFactory factory) Adds anLazyHeaderFactorythat will be used to construct a value for the given key lazily on a background thread.Adds a value for the given header and returns this builder.build()Returns a new immutableLazyHeadersobject.setHeader(String key, LazyHeaderFactory factory) Replaces all existingLazyHeaderFactorysfor the given key with the givenLazyHeaderFactory.Replaces all existingLazyHeaderFactorysfor the given key with the givenLazyHeaderFactory.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
addHeader
Adds a value for the given header and returns this builder.Use
addHeader(String, LazyHeaderFactory)if obtaining the value requires I/O (i.e. an OAuth token).- See Also:
-
addHeader
Adds anLazyHeaderFactorythat 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
-
setHeader
Replaces all existingLazyHeaderFactorysfor the given key with the givenLazyHeaderFactory.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). -
setHeader
Replaces all existingLazyHeaderFactorysfor the given key with the givenLazyHeaderFactory.If the given value is
null, the header at the given key will be removed. -
build
Returns a new immutableLazyHeadersobject.
-