Package anbxj
Class Channel_ProtobufSerializer.OpaqueStepDescriptor
java.lang.Object
anbxj.Channel_ProtobufSerializer.OpaqueStepDescriptor
- All Implemented Interfaces:
Channel_ProtobufSerializer.StepDescriptor
- Enclosing class:
Channel_ProtobufSerializer
public static class Channel_ProtobufSerializer.OpaqueStepDescriptor
extends Object
implements Channel_ProtobufSerializer.StepDescriptor
A
Channel_ProtobufSerializer.StepDescriptor implementation that wraps a Protobuf message
containing an opaque bytes payload.
This class is useful when a Protobuf message type is defined with a single
field bytes payload and the actual data is a serialised Java object.
It delegates the low-level Protobuf operations to a
Channel_ProtobufOpaqueWrapper.
The descriptor performs the following conversions:
- toProtobuf: Serialise the Java object to bytes, then set the
payloadfield of the Protobuf message. - toJavaObject: Extract the payload bytes from the Protobuf message, then deserialise them back into a Java object.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpaqueStepDescriptor(com.google.protobuf.Message defaultInstance) Constructs anOpaqueStepDescriptorfor a given Protobuf message type. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.protobuf.MessageparseFrom(byte[] data) Parses a Protobuf message from its binary representation.toJavaObject(com.google.protobuf.Message protoMsg) Extracts the payload from a Protobuf message and deserialises it back into a Java object.com.google.protobuf.MessagetoProtobuf(Object javaObj) Converts a Java object into a Protobuf message of the configured type by serialising the object into a byte array and setting it as the message'spayloadfield.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface anbxj.Channel_ProtobufSerializer.StepDescriptor
getInnerPayloadDescriptor
-
Constructor Details
-
OpaqueStepDescriptor
public OpaqueStepDescriptor(com.google.protobuf.Message defaultInstance) Constructs anOpaqueStepDescriptorfor a given Protobuf message type.- Parameters:
defaultInstance- the default (empty) instance of the Protobuf message type that must contain abytes payloadfield.
-
-
Method Details
-
toProtobuf
Converts a Java object into a Protobuf message of the configured type by serialising the object into a byte array and setting it as the message'spayloadfield.- Specified by:
toProtobufin interfaceChannel_ProtobufSerializer.StepDescriptor- Parameters:
javaObj- the Java object to be serialised and wrapped; must not benull- Returns:
- a Protobuf message containing the serialised object as payload
- Throws:
IOException- if serialisation or Protobuf construction fails
-
parseFrom
Parses a Protobuf message from its binary representation.- Specified by:
parseFromin interfaceChannel_ProtobufSerializer.StepDescriptor- Parameters:
data- the raw Protobuf serialised bytes- Returns:
- the parsed Protobuf message
- Throws:
IOException- if parsing fails
-
toJavaObject
Extracts the payload from a Protobuf message and deserialises it back into a Java object.- Specified by:
toJavaObjectin interfaceChannel_ProtobufSerializer.StepDescriptor- Parameters:
protoMsg- the Protobuf message (must be of the type this descriptor was created for)- Returns:
- the original Java object that was previously serialised into the payload
- Throws:
IOException- if deserialisation fails (including when the class is not found)
-