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 payload field 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

    Constructors
    Constructor
    Description
    OpaqueStepDescriptor(com.google.protobuf.Message defaultInstance)
    Constructs an OpaqueStepDescriptor for a given Protobuf message type.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.protobuf.Message
    parseFrom(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.Message
    toProtobuf(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's payload field.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OpaqueStepDescriptor

      public OpaqueStepDescriptor(com.google.protobuf.Message defaultInstance)
      Constructs an OpaqueStepDescriptor for a given Protobuf message type.
      Parameters:
      defaultInstance - the default (empty) instance of the Protobuf message type that must contain a bytes payload field.
  • Method Details

    • toProtobuf

      public com.google.protobuf.Message toProtobuf(Object javaObj) throws IOException
      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's payload field.
      Specified by:
      toProtobuf in interface Channel_ProtobufSerializer.StepDescriptor
      Parameters:
      javaObj - the Java object to be serialised and wrapped; must not be null
      Returns:
      a Protobuf message containing the serialised object as payload
      Throws:
      IOException - if serialisation or Protobuf construction fails
    • parseFrom

      public com.google.protobuf.Message parseFrom(byte[] data) throws IOException
      Parses a Protobuf message from its binary representation.
      Specified by:
      parseFrom in interface Channel_ProtobufSerializer.StepDescriptor
      Parameters:
      data - the raw Protobuf serialised bytes
      Returns:
      the parsed Protobuf message
      Throws:
      IOException - if parsing fails
    • toJavaObject

      public Object toJavaObject(com.google.protobuf.Message protoMsg) throws IOException
      Extracts the payload from a Protobuf message and deserialises it back into a Java object.
      Specified by:
      toJavaObject in interface Channel_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)