Contents
Class MapKeyMapCodec<V>
java.lang.Object
com.hypixel.hytale.codec.lookup.AMapProvidedMapCodec<Class<? extends V>, V, Codec<V>, MapKeyMapCodec.TypeMap<V>>
com.hypixel.hytale.codec.lookup.MapKeyMapCodec<V>
- All Implemented Interfaces:
Codec<MapKeyMapCodec.TypeMap<V>>, RawJsonCodec<MapKeyMapCodec.TypeMap<V>>, SchemaConvertable<MapKeyMapCodec.TypeMap<V>>, ValidatableCodec<MapKeyMapCodec.TypeMap<V>>
public class MapKeyMapCodec<V>
extends AMapProvidedMapCodec<Class<? extends V>, V, Codec<V>, MapKeyMapCodec.TypeMap<V>>
A codec that allows for new keys to be registered dynamically to it.
This codec encodes/decodes as a json object using the keys to work out the types of the values.
When registering the id is used as key in the object and the
codec will be used to decode the value.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classProvides type-safe methods accessing a map of class to value. -
Field Summary
Fields inherited from interface Codec
BASE64_PATTERN, BOOLEAN, BSON_DOCUMENT, BYTE, BYTE_ARRAY, DOUBLE, DOUBLE_ARRAY, DURATION, DURATION_SECONDS, FLOAT, FLOAT_ARRAY, INSTANT, INT_ARRAY, INTEGER, LOG_LEVEL, LONG, LONG_ARRAY, NULLABLE_BOOLEAN, PATH, SHORT, STRING, STRING_ARRAY, UUID_BINARY, UUID_STRING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecodeById(String id, org.bson.BsonValue value, ExtraInfo extraInfo) Deprecated, for removal: This API element is subject to removal in a future version.Exists to help with migrating datagetKeyForId(String id) voidhandleUnknown(MapKeyMapCodec.TypeMap<V> map, String key, RawJsonReader reader, ExtraInfo extraInfo) voidhandleUnknown(MapKeyMapCodec.TypeMap<V> map, String key, org.bson.BsonValue value, ExtraInfo extraInfo) <T extends V>
voidRegisters a type that can be decoded by this instance of the codec.<T extends V>
voidunregister(Class<T> tClass) Methods inherited from class AMapProvidedMapCodec
decode, decodeJson, encode, toSchema, validate, validateDefaultsMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface RawJsonCodec
decodeJsonMethods inherited from interface SchemaConvertable
toSchema
-
Constructor Details
-
MapKeyMapCodec
public MapKeyMapCodec() -
MapKeyMapCodec
public MapKeyMapCodec(boolean unmodifiable)
-
-
Method Details
-
register
public <T extends V> void register(@Nonnull Class<T> tClass, @Nonnull String id, @Nonnull Codec<T> codec) Registers a type that can be decoded by this instance of the codec.- Parameters:
id- The id to use when encoding/decoding this value from configcodec- The codec to use to encode/decode the value with
-
unregister
-
decodeById
@Nullable @Deprecated(forRemoval=true) public V decodeById(@Nonnull String id, org.bson.BsonValue value, ExtraInfo extraInfo) Deprecated, for removal: This API element is subject to removal in a future version.Exists to help with migrating data -
createMap
- Specified by:
createMapin classAMapProvidedMapCodec<Class<? extends V>, V, Codec<V>, MapKeyMapCodec.TypeMap<V>>
-
handleUnknown
public void handleUnknown(@Nonnull MapKeyMapCodec.TypeMap<V> map, @Nonnull String key, org.bson.BsonValue value, @Nonnull ExtraInfo extraInfo) - Overrides:
handleUnknownin classAMapProvidedMapCodec<Class<? extends V>, V, Codec<V>, MapKeyMapCodec.TypeMap<V>>
-
handleUnknown
public void handleUnknown(@Nonnull MapKeyMapCodec.TypeMap<V> map, @Nonnull String key, @Nonnull RawJsonReader reader, @Nonnull ExtraInfo extraInfo) throws IOException - Overrides:
handleUnknownin classAMapProvidedMapCodec<Class<? extends V>, V, Codec<V>, MapKeyMapCodec.TypeMap<V>>- Throws:
IOException
-
getKeyForId
-