- 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
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TDecodes the specified value to an object whose type is represented by the specified class.<T> TDecodes the specified value to an object of the specified type.<T> Aencode(T value) Encodes the specified value to the encoded type.<T> AEncodes the specified value whose type is represented by the specified class to the encoded type.<T> AEncodes the specified value whose type is the specified type to the encoded type.voidsetDecoders(List<CompoundDecoder<A, ?>> decoders) Sets the compound decoders used to decode objects.voidsetDefaultDecoder(Decoder<A, Object> defaultDecoder) Sets a default decoder to use when no compound decoder is able to decode an object.voidsetDefaultEncoder(Encoder<Object, A> defaultEncoder) Sets a default encoder to use when no compound encoder is able to encode an object.voidsetEncoders(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:DecoderDecodes the specified value to an object whose type is represented by the specified class.
-
decode
Description copied from interface:DecoderDecodes the specified value to an object of the specified type.
- Specified by:
decodein 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:EncoderEncodes the specified value to the encoded type.
-
encode
Description copied from interface:EncoderEncodes the specified value whose type is represented by the specified class to the encoded type.
- Specified by:
encodein 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:EncoderEncodes the specified value whose type is the specified type to the encoded type.
- Specified by:
encodein 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
-