Class DefaultDecoderFactory

java.lang.Object
com.lucimber.dbus.codec.decoder.DefaultDecoderFactory
All Implemented Interfaces:
DecoderFactory

public final class DefaultDecoderFactory extends Object implements DecoderFactory
Default implementation of DecoderFactory that provides decoders for all standard D-Bus types.

This factory uses a registry-based approach to create decoders, making it easy to extend with new types and improving performance by avoiding switch statements.

  • Constructor Details

    • DefaultDecoderFactory

      public DefaultDecoderFactory()
      Creates a new DefaultDecoderFactory with all standard D-Bus decoders registered.
  • Method Details

    • createDecoder

      public Decoder<ByteBuffer,DBusType> createDecoder(TypeCode typeCode) throws DecoderException
      Description copied from interface: DecoderFactory
      Creates a decoder for the specified D-Bus type code.
      Specified by:
      createDecoder in interface DecoderFactory
      Parameters:
      typeCode - the D-Bus type code to decode
      Returns:
      a decoder capable of decoding the specified type
      Throws:
      DecoderException - if no decoder is available for the type
    • createDecoder

      public Decoder<ByteBuffer,DBusType> createDecoder(Type type) throws DecoderException
      Description copied from interface: DecoderFactory
      Creates a decoder for the specified D-Bus type.
      Specified by:
      createDecoder in interface DecoderFactory
      Parameters:
      type - the D-Bus type to decode
      Returns:
      a decoder capable of decoding the specified type
      Throws:
      DecoderException - if no decoder is available for the type
    • canDecode

      public boolean canDecode(TypeCode typeCode)
      Description copied from interface: DecoderFactory
      Checks if a decoder is available for the specified type code.
      Specified by:
      canDecode in interface DecoderFactory
      Parameters:
      typeCode - the D-Bus type code to check
      Returns:
      true if a decoder is available, false otherwise
    • canDecode

      public boolean canDecode(Type type)
      Description copied from interface: DecoderFactory
      Checks if a decoder is available for the specified type.
      Specified by:
      canDecode in interface DecoderFactory
      Parameters:
      type - the D-Bus type to check
      Returns:
      true if a decoder is available, false otherwise
    • registerDecoder

      public void registerDecoder(TypeCode typeCode, DefaultDecoderFactory.DecoderCreator creator)
      Registers a custom decoder creator for a specific type code.
      Parameters:
      typeCode - the D-Bus type code
      creator - the decoder creator function