Class MessageValue


  • @API(EXPERIMENTAL)
    public class MessageValue
    extends Object
    A utility class for extracting data and meta-data from Protocol Buffer Messages, as used in the Record Layer.
    • Method Detail

      • getFieldValue

        @Nullable
        public static Object getFieldValue​(@Nonnull
                                           MessageOrBuilder message,
                                           @Nonnull
                                           List<String> fieldNames)
        Get the value of the (nested) field on the path from the message defined by fieldNames. The given field names define a path through the nested structure of the given message; this method traverses that path and returns the value at the leaf, using the return semantics of getFieldOnMessage(MessageOrBuilder, String).
        Parameters:
        message - a message
        fieldNames - a list of field names defining a path starting at message
        Returns:
        the value at the end of hte path
      • getFieldOnMessage

        @Nullable
        public static Object getFieldOnMessage​(@Nonnull
                                               MessageOrBuilder message,
                                               @Nonnull
                                               String fieldName)
        Get the value of the field with the given field name on the given message. If the field is repeated, the repeated values are combined into a list. If the field has a message type, the value is returned as a Message of that type. Otherwise, the field is returned as a primitive.
        Parameters:
        message - a message or builder to extract the field from
        fieldName - the field to extract
        Returns:
        the value of the field as described above