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 CodecRegistry
SINGLETON
Singleton instance of theDefaultCodecRegistry
for global access.
-
Constructor Summary
Constructors Constructor Description DefaultCodecRegistry()
Initializes a new instance ofDefaultCodecRegistry
with predefined codecs for commonly used data types.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(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> void
put(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 theDefaultCodecRegistry
for 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:
get
in interfaceCodecRegistry
- Type Parameters:
T
- The data type to be encoded or decoded.- Parameters:
key
- TheCodecRegistryKey
representing the data type.- Returns:
- The
Codec
associated with the key, ornull
if 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:
put
in interfaceCodecRegistry
- Type Parameters:
T
- The data type to be encoded or decoded.- Parameters:
key
- TheCodecRegistryKey
representing the data type.codec
- TheCodec
to associate with the key.
-
contains
public boolean contains(CodecRegistryKey key)
Checks if the registry contains a codec for the specified key.- Specified by:
contains
in interfaceCodecRegistry
- Parameters:
key
- TheCodecRegistryKey
representing the data type.- Returns:
true
if a codec for the key is registered; otherwise,false
.
-
-