Package com.lucimber.dbus.codec.decoder
Class DefaultDecoderFactory
java.lang.Object
com.lucimber.dbus.codec.decoder.DefaultDecoderFactory
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Functional interface for creating decoders. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DefaultDecoderFactory with all standard D-Bus decoders registered. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if a decoder is available for the specified type.boolean
Checks if a decoder is available for the specified type code.createDecoder
(Type type) Creates a decoder for the specified D-Bus type.createDecoder
(TypeCode typeCode) Creates a decoder for the specified D-Bus type code.void
registerDecoder
(TypeCode typeCode, DefaultDecoderFactory.DecoderCreator creator) Registers a custom decoder creator for a specific type code.
-
Constructor Details
-
DefaultDecoderFactory
public DefaultDecoderFactory()Creates a new DefaultDecoderFactory with all standard D-Bus decoders registered.
-
-
Method Details
-
createDecoder
Description copied from interface:DecoderFactory
Creates a decoder for the specified D-Bus type code.- Specified by:
createDecoder
in interfaceDecoderFactory
- 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
Description copied from interface:DecoderFactory
Creates a decoder for the specified D-Bus type.- Specified by:
createDecoder
in interfaceDecoderFactory
- 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
Description copied from interface:DecoderFactory
Checks if a decoder is available for the specified type code.- Specified by:
canDecode
in interfaceDecoderFactory
- Parameters:
typeCode
- the D-Bus type code to check- Returns:
- true if a decoder is available, false otherwise
-
canDecode
Description copied from interface:DecoderFactory
Checks if a decoder is available for the specified type.- Specified by:
canDecode
in interfaceDecoderFactory
- Parameters:
type
- the D-Bus type to check- Returns:
- true if a decoder is available, false otherwise
-
registerDecoder
Registers a custom decoder creator for a specific type code.- Parameters:
typeCode
- the D-Bus type codecreator
- the decoder creator function
-