Class MessageSetSchema<T>

java.lang.Object
com.google.protobuf.MessageSetSchema<T>
All Implemented Interfaces:
Schema<T>

@CheckReturnValue final class MessageSetSchema<T> extends Object implements Schema<T>
Schema used for proto2 messages using message_set_wireformat.
  • Field Details

    • defaultInstance

      private final MessageLite defaultInstance
    • unknownFieldSchema

      private final UnknownFieldSchema<?,?> unknownFieldSchema
    • hasExtensions

      private final boolean hasExtensions
    • extensionSchema

      private final ExtensionSchema<?> extensionSchema
  • Constructor Details

  • Method Details

    • newSchema

      static <T> MessageSetSchema<T> newSchema(UnknownFieldSchema<?,?> unknownFieldSchema, ExtensionSchema<?> extensionSchema, MessageLite defaultInstance)
    • newInstance

      public T newInstance()
      Description copied from interface: Schema
      Creates a new instance of the message class.
      Specified by:
      newInstance in interface Schema<T>
    • equals

      public boolean equals(T message, T other)
      Description copied from interface: Schema
      Determine of the two messages are equal.
      Specified by:
      equals in interface Schema<T>
    • hashCode

      public int hashCode(T message)
      Description copied from interface: Schema
      Compute a hashCode for the message.
      Specified by:
      hashCode in interface Schema<T>
    • mergeFrom

      public void mergeFrom(T message, T other)
      Description copied from interface: Schema
      Merge values from other into message. This method doesn't make the message immutable. To make the message immutable after merging, use Schema.makeImmutable(T).
      Specified by:
      mergeFrom in interface Schema<T>
    • writeTo

      public void writeTo(T message, Writer writer) throws IOException
      Description copied from interface: Schema
      Writes the given message to the target Writer.
      Specified by:
      writeTo in interface Schema<T>
      Throws:
      IOException
    • writeUnknownFieldsHelper

      private <UT, UB> void writeUnknownFieldsHelper(UnknownFieldSchema<UT,UB> unknownFieldSchema, T message, Writer writer) throws IOException
      A helper method for wildcard capture of unknownFieldSchema. See: https://docs.oracle.com/javase/tutorial/java/generics/capture.html
      Throws:
      IOException
    • mergeFrom

      public void mergeFrom(T message, byte[] data, int position, int limit, ArrayDecoders.Registers registers) throws IOException
      Description copied from interface: Schema
      Like the above but parses from a byte[] without extensions. Entry point of fast path. Note that this method may throw IndexOutOfBoundsException if the input data is not valid protobuf wire format. Protobuf public API methods should catch and convert that exception to InvalidProtocolBufferException.
      Specified by:
      mergeFrom in interface Schema<T>
      Throws:
      IOException
    • mergeFrom

      public void mergeFrom(T message, Reader reader, ExtensionRegistryLite extensionRegistry) throws IOException
      Description copied from interface: Schema
      Reads fields from the given Reader and merges them into the message. It doesn't make the message immutable after parsing is done. To make the message immutable, use Schema.makeImmutable(T).
      Specified by:
      mergeFrom in interface Schema<T>
      Throws:
      IOException
    • mergeFromHelper

      private <UT, UB, ET extends FieldSet.FieldDescriptorLite<ET>> void mergeFromHelper(UnknownFieldSchema<UT,UB> unknownFieldSchema, ExtensionSchema<ET> extensionSchema, T message, Reader reader, ExtensionRegistryLite extensionRegistry) throws IOException
      A helper method for wildcard capture of unknownFieldSchema. See: https://docs.oracle.com/javase/tutorial/java/generics/capture.html
      Throws:
      IOException
    • makeImmutable

      public void makeImmutable(T message)
      Description copied from interface: Schema
      Marks repeated/map/extension/unknown fields as immutable.
      Specified by:
      makeImmutable in interface Schema<T>
    • parseMessageSetItemOrUnknownField

      private <UT, UB, ET extends FieldSet.FieldDescriptorLite<ET>> boolean parseMessageSetItemOrUnknownField(Reader reader, ExtensionRegistryLite extensionRegistry, ExtensionSchema<ET> extensionSchema, FieldSet<ET> extensions, UnknownFieldSchema<UT,UB> unknownFieldSchema, UB unknownFields) throws IOException
      Throws:
      IOException
    • isInitialized

      public final boolean isInitialized(T message)
      Description copied from interface: Schema
      Checks whether all required fields are set.
      Specified by:
      isInitialized in interface Schema<T>
    • getSerializedSize

      public int getSerializedSize(T message)
      Description copied from interface: Schema
      Compute the serialized size of the message.
      Specified by:
      getSerializedSize in interface Schema<T>
    • getUnknownFieldsSerializedSize

      private <UT, UB> int getUnknownFieldsSerializedSize(UnknownFieldSchema<UT,UB> schema, T message)