java.lang.Object
io.inverno.mod.base.converter.CompositeDecoder<From>
- Type Parameters:
From- the decoded type
A composite decoder relies on multiple CompoundDecoder to decode objects.
Such implementation makes it possible to create extensible decoder able to decode various type of objects by composition of many specific compound decoders.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
-
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.protected <T> CompoundDecoder<From, T> getDecoder(Type type) Returns the first compound decoder that can decode the specified type.voidsetDecoders(List<CompoundDecoder<From, ?>> decoders) Sets the compound decoders used to decode objects.voidsetDefaultDecoder(Decoder<From, Object> defaultDecoder) Sets a default decoder to use when no compound decoder is able to decode an object.
-
Constructor Details
-
CompositeDecoder
public CompositeDecoder()Creates a composite decoder.
-
-
Method Details
-
setDecoders
Sets the compound decoders used to decode objects.
- Parameters:
decoders- a list of compound decoders
-
setDefaultDecoder
Sets a default decoder to use when no compound decoder is able to decode an object.
- Parameters:
defaultDecoder- the default decoder
-
getDecoder
Returns the first compound decoder that can decode the specified type.
- Type Parameters:
T- the type of object decoded by the returned decoder- Parameters:
type- the type to decode- Returns:
- a compound decoder
- Throws:
DecoderNotFoundException- if no decoder can decode the specified type
-
decode
Description copied from interface:DecoderDecodes the specified value to an object whose type is represented by the specified class.
- Specified by:
decodein interfaceDecoder<From,Object> - Type Parameters:
T- the type of the decoded object- Parameters:
value- the object to decodetype- the class of the decoded object- Returns:
- a decoded object
- Throws:
DecoderNotFoundException
-
decode
Description copied from interface:DecoderDecodes the specified value to an object of the specified type.
- Specified by:
decodein interfaceDecoder<From,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
-