- All Known Implementing Classes:
BrotliBodyDecoderFactory
,DeflateBodyDecoderFactory
,GzipBodyDecoderFactory
- Enclosing interface:
BodyDecoder<T>
public static interface BodyDecoder.Factory
A factory of
BodyDecoders
for some defined encoding. BodyDecoder.Factory
implementations are normally registered as service-providers by means described in the ServiceLoader
class.-
Method Summary
Modifier and TypeMethodDescription<T> BodyDecoder
<T> create
(HttpResponse.BodySubscriber<T> downstream) Creates and returns aBodyDecoder
with the given downstream.<T> BodyDecoder
<T> create
(HttpResponse.BodySubscriber<T> downstream, Executor executor) Creates and returns aBodyDecoder
with the given downstream and executor.encoding()
Returns the encoding used byBodyDecoders
created by this factory.static Optional
<BodyDecoder.Factory> getFactory
(String encoding) Returns anOptional
containing the factory registered for the given encoding.static Map
<String, BodyDecoder.Factory> Returns an immutable map that case-insensitively maps encodings to their corresponding registered factories.static List
<BodyDecoder.Factory> Returns an immutable list of the registered factories.
-
Method Details
-
encoding
String encoding()Returns the encoding used byBodyDecoders
created by this factory. -
create
Creates and returns aBodyDecoder
with the given downstream.- Type Parameters:
T
- the body type- Parameters:
downstream
- the downstream subscriber
-
create
Creates and returns aBodyDecoder
with the given downstream and executor.- Type Parameters:
T
- the body type- Parameters:
downstream
- the downstream subscriberexecutor
- the decoder's executor
-
installedFactories
Returns an immutable list of the registered factories.- Throws:
ServiceConfigurationError
- if an error occurs while loading the registered factories
-
installedBindings
Returns an immutable map that case-insensitively maps encodings to their corresponding registered factories. If more than one factory is registered for a given encoding, it is unspecified which one ends up being in the map. However, decoders provided by this module are overridable. -
getFactory
Returns anOptional
containing the factory registered for the given encoding. An empty optional is returned if no such factory exists.- Parameters:
encoding
- the factory's encoding
-