Package com.fauna.codec
Class DefaultCodecRegistry
- java.lang.Object
-
- com.fauna.codec.DefaultCodecRegistry
-
- All Implemented Interfaces:
CodecRegistry
public final class DefaultCodecRegistry extends java.lang.Object implements CodecRegistry
The default codec registry for Fauna serialization and deserialization.This registry provides pre-defined codecs for common data types, enabling serialization to and deserialization from FQL.
-
-
Field Summary
Fields Modifier and Type Field Description static CodecRegistrySINGLETONSingleton instance of theDefaultCodecRegistryfor global access.
-
Constructor Summary
Constructors Constructor Description DefaultCodecRegistry()Initializes a new instance ofDefaultCodecRegistrywith predefined codecs for commonly used data types.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(CodecRegistryKey key)Checks if the registry contains a codec for the specified key.<T> Codec<T>get(CodecRegistryKey key)Retrieves the codec associated with the specified key, if it exists.<T> voidput(CodecRegistryKey key, Codec<T> codec)Registers a new codec for the specified key in the registry.
-
-
-
Field Detail
-
SINGLETON
public static final CodecRegistry SINGLETON
Singleton instance of theDefaultCodecRegistryfor global access.
-
-
Method Detail
-
get
public <T> Codec<T> get(CodecRegistryKey key)
Retrieves the codec associated with the specified key, if it exists.- Specified by:
getin interfaceCodecRegistry- Type Parameters:
T- The data type to be encoded or decoded.- Parameters:
key- TheCodecRegistryKeyrepresenting the data type.- Returns:
- The
Codecassociated with the key, ornullif not found.
-
put
public <T> void put(CodecRegistryKey key, Codec<T> codec)
Registers a new codec for the specified key in the registry.- Specified by:
putin interfaceCodecRegistry- Type Parameters:
T- The data type to be encoded or decoded.- Parameters:
key- TheCodecRegistryKeyrepresenting the data type.codec- TheCodecto associate with the key.
-
contains
public boolean contains(CodecRegistryKey key)
Checks if the registry contains a codec for the specified key.- Specified by:
containsin interfaceCodecRegistry- Parameters:
key- TheCodecRegistryKeyrepresenting the data type.- Returns:
trueif a codec for the key is registered; otherwise,false.
-
-