Class MapLiaison
- All Implemented Interfaces:
TypeLiaison
This liaison will match all Map<K, V>. It will use the relevant serializers for the key and value type,
respectively, to build the relevant map.
Limitations
This liaison does not, and cannot, preserve entry metadata, such as comments, on map values across separate
acts of deserialization and serialization. Only a SerializeDeserialize.deserializeUpdate(space.arim.dazzleconf.engine.DeserializeInput, space.arim.dazzleconf.engine.SerializeOutput) operation can
preserve this entry metadata.
Duplicate Keys
Note that despite this liaison using a DataTree as its input, it is still
possible for keys to be deserialized in a way that produces duplicates. Deserialization, in general, is not a 1-to-1
mapping, and the key type can implement different equality semantics than the input data, in addition to mapping
from different input types. For example, "1" and 1 might both be deserialized as 1.
The policy of this liaison is to silently skip keys that become duplicated due to deserialization. This behavior was chosen because such duplication usually arises from user input. There is no sort of "merge" algorithm for values; additionally, it is not defined which key will be selected.
Serialization can also produce duplicate keys. This can happen if the key serializer implementation chooses to
produce identical output keys, either during regular serialization or during a read-update operation via
SerializeDeserialize.deserializeUpdate(DeserializeInput, SerializeOutput). This liaison considers such
duplication a mistake, and it will throw a DeveloperMistakeException if conflicting output keys are detected.
Consistent Order
This liaison provides a consistent order across deserialization and re-serialization. It is implemented internally
over an immutable wrapper of LinkedHashSet.
-
Nested Class Summary
Nested classes/interfaces inherited from interface space.arim.dazzleconf.engine.TypeLiaison
TypeLiaison.Agent<V>, TypeLiaison.DefaultInit<V>, TypeLiaison.Handshake -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<V> @Nullable TypeLiaison.Agent<V> makeAgent(@NonNull TypeToken<V> typeToken, @NonNull TypeLiaison.Handshake handshake) Attempts to support the following type.
-
Constructor Details
-
MapLiaison
public MapLiaison()Creates the liaison
-
-
Method Details
-
makeAgent
@SideEffectFree public <V> @Nullable TypeLiaison.Agent<V> makeAgent(@NonNull TypeToken<V> typeToken, @NonNull TypeLiaison.Handshake handshake) Description copied from interface:TypeLiaisonAttempts to support the following type.If supported, an agent is returned that handles type serialization, deserialization, and defaults. Note that implementations may need casting at the source level to satisfy the generic argument of the token requested.
- Specified by:
makeAgentin interfaceTypeLiaison- Type Parameters:
V- the type being requested- Parameters:
typeToken- the type tokenhandshake- the handshake- Returns:
- the agent if supported, or null otherwise
-