Class ClassCodec<T>

  • Type Parameters:
    T - The type of the class to encode/decode.
    All Implemented Interfaces:
    Codec<T>

    public final class ClassCodec<T>
    extends BaseCodec<T>
    A codec for encoding and decoding Java classes, handling Fauna-specific annotations and types.
    • Constructor Detail

      • ClassCodec

        public ClassCodec​(java.lang.Class<T> ty,
                          CodecProvider provider)
        Constructs a ClassCodec for a given type, initializing field mappings based on Fauna annotations.
        Parameters:
        ty - The class type.
        provider - The codec provider for resolving codecs for field types.
    • Method Detail

      • decode

        public T decode​(UTF8FaunaParser parser)
                 throws CodecException
        Description copied from interface: Codec
        Decodes an object from the provided UTF8FaunaParser.
        Parameters:
        parser - The parser to use for reading and decoding the data.
        Returns:
        The decoded object of type T.
        Throws:
        CodecException - If an error occurs during decoding.
      • encode

        public void encode​(UTF8FaunaGenerator gen,
                           T obj)
                    throws CodecException
        Description copied from interface: Codec
        Encodes the specified object using the provided UTF8FaunaGenerator.
        Parameters:
        gen - The generator to use for writing and encoding the data.
        obj - The object of type T to encode.
        Throws:
        CodecException - If an error occurs during encoding.
      • getCodecClass

        public java.lang.Class<T> getCodecClass()
        Description copied from interface: Codec
        Gets the class associated with this codec.
        Returns:
        The Class type that this codec handles.
      • getSupportedTypes

        public FaunaType[] getSupportedTypes()
        Description copied from interface: Codec
        Gets the set of supported Fauna data types for this codec.
        Returns:
        An array of FaunaType values representing the supported types.