Package space.arim.dazzleconf.serialiser
Interface Decomposer
public interface Decomposer
A complement to
Note that, unlike a
FlexibleType which allows objects to be broken down during reserialisation. Note that, unlike a
FlexibleType, a decomposer does not store any value paired with it.- Author:
- A248
-
Method Summary
Modifier and TypeMethodDescription<T> ObjectDecomposes an object of a certain type, using a value serializer if necessary.<E> Collection<Object>decomposeCollection(Class<E> elementType, Collection<? extends E> collection) Decomposes all the elements of a collection.decomposeMap(Class<K> keyType, Class<V> valueType, Map<? extends K, ? extends V> map) Decomposes all the keys and values of a map.
-
Method Details
-
decomposeCollection
<E> Collection<Object> decomposeCollection(Class<E> elementType, Collection<? extends E> collection) Decomposes all the elements of a collection. Equivalent to callingdecompose(Class, Object)to process each element.
The returned collection may or may not be mutable. The caller should create a copy if modification is desired.- Type Parameters:
E- the element type- Parameters:
elementType- the element type classcollection- the collection to decompose- Returns:
- the serialised form of the object
-
decomposeMap
<K,V> Map<Object,Object> decomposeMap(Class<K> keyType, Class<V> valueType, Map<? extends K, ? extends V> map) Decomposes all the keys and values of a map. Equivalent to callingdecompose(Class, Object)to process each key and value.
The returned map may or may not be mutable. The caller should create a copy if modification is desired.- Type Parameters:
K- the key typeV- the value type- Parameters:
keyType- the key type classvalueType- the value type classmap- the map to decompose- Returns:
- the serialised form of the object
-
decompose
Decomposes an object of a certain type, using a value serializer if necessary.
If the type in question is not a String, primitive, or enum, then the appropriate value serializer is used. If no value serializer fortypeexists, IllDefinedConfigException is thrown.- Type Parameters:
T- the type according to which to serialise- Parameters:
type- the type of the object according to which to serialisevalue- the object to serialise- Returns:
- the serialised form of the object
- Throws:
IllDefinedConfigException- if no value serializer could be found for the type
-