- Type Parameters:
A
- the converted type
- Direct Known Subclasses:
StringCompositeConverter
A composite converter relies on multiple CompoundEncoder
and
CompoundDecoder
to convert objects.
Such implementation makes it possible to create extensible converter able to convert various type of objects by composition of many specific compound encoders and decoders.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
Decodes the specified value to an object whose type is represented by the specified class.<T> T
Decodes the specified value to an object of the specified type.<T> A
encode
(T value) Encodes the specified value to the encoded type.<T> A
Encodes the specified value whose type is represented by the specified class to the encoded type.<T> A
Encodes the specified value whose type is the specified type to the encoded type.void
setDecoders
(List<CompoundDecoder<A, ?>> decoders) Sets the compound decoders used to decode objects.void
setDefaultDecoder
(Decoder<A, Object> defaultDecoder) Sets a default decoder to use when no compound decoder is able to decode an object.void
setDefaultEncoder
(Encoder<Object, A> defaultEncoder) Sets a default encoder to use when no compound encoder is able to encode an object.void
setEncoders
(List<CompoundEncoder<?, A>> encoders) Sets the compound encoders used to encode objects.
-
Constructor Details
-
CompositeConverter
public CompositeConverter()Creates a composite converter.
-
-
Method Details
-
setDecoders
Sets the compound decoders used to decode objects.
- Parameters:
decoders
- a list of compound decoders
-
setEncoders
Sets the compound encoders used to encode objects.
- Parameters:
encoders
- a list of compound encoders
-
setDefaultDecoder
Sets a default decoder to use when no compound decoder is able to decode an object.
- Parameters:
defaultDecoder
- the default decoder
-
setDefaultEncoder
Sets a default encoder to use when no compound encoder is able to encode an object.
- Parameters:
defaultEncoder
- the default decoder
-
decode
Description copied from interface:Decoder
Decodes the specified value to an object whose type is represented by the specified class.
-
decode
Description copied from interface:Decoder
Decodes the specified value to an object of the specified type.
- Specified by:
decode
in interfaceDecoder<A,
Object> - Type Parameters:
T
- the type of the decoded object- Parameters:
value
- the object to decodetype
- the type of the decoded object- Returns:
- a decoded object
- Throws:
ConverterException
- if there was an error decoding the value
-
encode
Description copied from interface:Encoder
Encodes the specified value to the encoded type.
-
encode
Description copied from interface:Encoder
Encodes the specified value whose type is represented by the specified class to the encoded type.
- Specified by:
encode
in interfaceEncoder<Object,
A> - Type Parameters:
T
- the type of the decoded object- Parameters:
value
- the object to encodetype
- the class of the decoded object- Returns:
- an encoded object
- Throws:
ConverterException
- if there was an error encoding the value
-
encode
Description copied from interface:Encoder
Encodes the specified value whose type is the specified type to the encoded type.
- Specified by:
encode
in interfaceEncoder<Object,
A> - Type Parameters:
T
- the type of the decoded object- Parameters:
value
- the object to encodetype
- the type of the decoded object- Returns:
- an encoded object
- Throws:
ConverterException
- if there was an error encoding the value
-