Class PubsubMessage.Builder

  • All Implemented Interfaces:
    com.google.protobuf.Message.Builder, com.google.protobuf.MessageLite.Builder, com.google.protobuf.MessageLiteOrBuilder, com.google.protobuf.MessageOrBuilder, PubsubMessageOrBuilder, Cloneable
    Enclosing class:
    PubsubMessage

    public static final class PubsubMessage.Builder
    extends com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
    implements PubsubMessageOrBuilder
     A message that is published by publishers and consumed by subscribers. The
     message must contain either a non-empty data field or at least one attribute.
     Note that client libraries represent this object differently
     depending on the language. See the corresponding [client library
     documentation](https://cloud.google.com/pubsub/docs/reference/libraries) for
     more information. See [quotas and limits]
     (https://cloud.google.com/pubsub/quotas) for more information about message
     limits.
     
    Protobuf type google.pubsub.v1.PubsubMessage
    • Method Detail

      • getDescriptor

        public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
      • internalGetMapField

        protected com.google.protobuf.MapField internalGetMapField​(int number)
        Overrides:
        internalGetMapField in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • internalGetMutableMapField

        protected com.google.protobuf.MapField internalGetMutableMapField​(int number)
        Overrides:
        internalGetMutableMapField in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • internalGetFieldAccessorTable

        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
        Specified by:
        internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • clear

        public PubsubMessage.Builder clear()
        Specified by:
        clear in interface com.google.protobuf.Message.Builder
        Specified by:
        clear in interface com.google.protobuf.MessageLite.Builder
        Overrides:
        clear in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • getDescriptorForType

        public com.google.protobuf.Descriptors.Descriptor getDescriptorForType()
        Specified by:
        getDescriptorForType in interface com.google.protobuf.Message.Builder
        Specified by:
        getDescriptorForType in interface com.google.protobuf.MessageOrBuilder
        Overrides:
        getDescriptorForType in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • getDefaultInstanceForType

        public PubsubMessage getDefaultInstanceForType()
        Specified by:
        getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuilder
        Specified by:
        getDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilder
      • build

        public PubsubMessage build()
        Specified by:
        build in interface com.google.protobuf.Message.Builder
        Specified by:
        build in interface com.google.protobuf.MessageLite.Builder
      • buildPartial

        public PubsubMessage buildPartial()
        Specified by:
        buildPartial in interface com.google.protobuf.Message.Builder
        Specified by:
        buildPartial in interface com.google.protobuf.MessageLite.Builder
      • clone

        public PubsubMessage.Builder clone()
        Specified by:
        clone in interface com.google.protobuf.Message.Builder
        Specified by:
        clone in interface com.google.protobuf.MessageLite.Builder
        Overrides:
        clone in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • setField

        public PubsubMessage.Builder setField​(com.google.protobuf.Descriptors.FieldDescriptor field,
                                              Object value)
        Specified by:
        setField in interface com.google.protobuf.Message.Builder
        Overrides:
        setField in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • clearField

        public PubsubMessage.Builder clearField​(com.google.protobuf.Descriptors.FieldDescriptor field)
        Specified by:
        clearField in interface com.google.protobuf.Message.Builder
        Overrides:
        clearField in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • clearOneof

        public PubsubMessage.Builder clearOneof​(com.google.protobuf.Descriptors.OneofDescriptor oneof)
        Specified by:
        clearOneof in interface com.google.protobuf.Message.Builder
        Overrides:
        clearOneof in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • setRepeatedField

        public PubsubMessage.Builder setRepeatedField​(com.google.protobuf.Descriptors.FieldDescriptor field,
                                                      int index,
                                                      Object value)
        Specified by:
        setRepeatedField in interface com.google.protobuf.Message.Builder
        Overrides:
        setRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • addRepeatedField

        public PubsubMessage.Builder addRepeatedField​(com.google.protobuf.Descriptors.FieldDescriptor field,
                                                      Object value)
        Specified by:
        addRepeatedField in interface com.google.protobuf.Message.Builder
        Overrides:
        addRepeatedField in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • mergeFrom

        public PubsubMessage.Builder mergeFrom​(com.google.protobuf.Message other)
        Specified by:
        mergeFrom in interface com.google.protobuf.Message.Builder
        Overrides:
        mergeFrom in class com.google.protobuf.AbstractMessage.Builder<PubsubMessage.Builder>
      • isInitialized

        public final boolean isInitialized()
        Specified by:
        isInitialized in interface com.google.protobuf.MessageLiteOrBuilder
        Overrides:
        isInitialized in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • mergeFrom

        public PubsubMessage.Builder mergeFrom​(com.google.protobuf.CodedInputStream input,
                                               com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                                        throws IOException
        Specified by:
        mergeFrom in interface com.google.protobuf.Message.Builder
        Specified by:
        mergeFrom in interface com.google.protobuf.MessageLite.Builder
        Overrides:
        mergeFrom in class com.google.protobuf.AbstractMessage.Builder<PubsubMessage.Builder>
        Throws:
        IOException
      • getData

        public com.google.protobuf.ByteString getData()
         The message data field. If this field is empty, the message must contain
         at least one attribute.
         
        bytes data = 1;
        Specified by:
        getData in interface PubsubMessageOrBuilder
        Returns:
        The data.
      • setData

        public PubsubMessage.Builder setData​(com.google.protobuf.ByteString value)
         The message data field. If this field is empty, the message must contain
         at least one attribute.
         
        bytes data = 1;
        Parameters:
        value - The data to set.
        Returns:
        This builder for chaining.
      • clearData

        public PubsubMessage.Builder clearData()
         The message data field. If this field is empty, the message must contain
         at least one attribute.
         
        bytes data = 1;
        Returns:
        This builder for chaining.
      • getAttributesCount

        public int getAttributesCount()
        Description copied from interface: PubsubMessageOrBuilder
         Attributes for this message. If this field is empty, the message must
         contain non-empty data. This can be used to filter messages on the
         subscription.
         
        map<string, string> attributes = 2;
        Specified by:
        getAttributesCount in interface PubsubMessageOrBuilder
      • containsAttributes

        public boolean containsAttributes​(String key)
         Attributes for this message. If this field is empty, the message must
         contain non-empty data. This can be used to filter messages on the
         subscription.
         
        map<string, string> attributes = 2;
        Specified by:
        containsAttributes in interface PubsubMessageOrBuilder
      • getAttributesMap

        public Map<String,​String> getAttributesMap()
         Attributes for this message. If this field is empty, the message must
         contain non-empty data. This can be used to filter messages on the
         subscription.
         
        map<string, string> attributes = 2;
        Specified by:
        getAttributesMap in interface PubsubMessageOrBuilder
      • getAttributesOrDefault

        public String getAttributesOrDefault​(String key,
                                             String defaultValue)
         Attributes for this message. If this field is empty, the message must
         contain non-empty data. This can be used to filter messages on the
         subscription.
         
        map<string, string> attributes = 2;
        Specified by:
        getAttributesOrDefault in interface PubsubMessageOrBuilder
      • getAttributesOrThrow

        public String getAttributesOrThrow​(String key)
         Attributes for this message. If this field is empty, the message must
         contain non-empty data. This can be used to filter messages on the
         subscription.
         
        map<string, string> attributes = 2;
        Specified by:
        getAttributesOrThrow in interface PubsubMessageOrBuilder
      • removeAttributes

        public PubsubMessage.Builder removeAttributes​(String key)
         Attributes for this message. If this field is empty, the message must
         contain non-empty data. This can be used to filter messages on the
         subscription.
         
        map<string, string> attributes = 2;
      • getMutableAttributes

        @Deprecated
        public Map<String,​String> getMutableAttributes()
        Deprecated.
        Use alternate mutation accessors instead.
      • putAttributes

        public PubsubMessage.Builder putAttributes​(String key,
                                                   String value)
         Attributes for this message. If this field is empty, the message must
         contain non-empty data. This can be used to filter messages on the
         subscription.
         
        map<string, string> attributes = 2;
      • putAllAttributes

        public PubsubMessage.Builder putAllAttributes​(Map<String,​String> values)
         Attributes for this message. If this field is empty, the message must
         contain non-empty data. This can be used to filter messages on the
         subscription.
         
        map<string, string> attributes = 2;
      • getMessageId

        public String getMessageId()
         ID of this message, assigned by the server when the message is published.
         Guaranteed to be unique within the topic. This value may be read by a
         subscriber that receives a `PubsubMessage` via a `Pull` call or a push
         delivery. It must not be populated by the publisher in a `Publish` call.
         
        string message_id = 3;
        Specified by:
        getMessageId in interface PubsubMessageOrBuilder
        Returns:
        The messageId.
      • getMessageIdBytes

        public com.google.protobuf.ByteString getMessageIdBytes()
         ID of this message, assigned by the server when the message is published.
         Guaranteed to be unique within the topic. This value may be read by a
         subscriber that receives a `PubsubMessage` via a `Pull` call or a push
         delivery. It must not be populated by the publisher in a `Publish` call.
         
        string message_id = 3;
        Specified by:
        getMessageIdBytes in interface PubsubMessageOrBuilder
        Returns:
        The bytes for messageId.
      • setMessageId

        public PubsubMessage.Builder setMessageId​(String value)
         ID of this message, assigned by the server when the message is published.
         Guaranteed to be unique within the topic. This value may be read by a
         subscriber that receives a `PubsubMessage` via a `Pull` call or a push
         delivery. It must not be populated by the publisher in a `Publish` call.
         
        string message_id = 3;
        Parameters:
        value - The messageId to set.
        Returns:
        This builder for chaining.
      • clearMessageId

        public PubsubMessage.Builder clearMessageId()
         ID of this message, assigned by the server when the message is published.
         Guaranteed to be unique within the topic. This value may be read by a
         subscriber that receives a `PubsubMessage` via a `Pull` call or a push
         delivery. It must not be populated by the publisher in a `Publish` call.
         
        string message_id = 3;
        Returns:
        This builder for chaining.
      • setMessageIdBytes

        public PubsubMessage.Builder setMessageIdBytes​(com.google.protobuf.ByteString value)
         ID of this message, assigned by the server when the message is published.
         Guaranteed to be unique within the topic. This value may be read by a
         subscriber that receives a `PubsubMessage` via a `Pull` call or a push
         delivery. It must not be populated by the publisher in a `Publish` call.
         
        string message_id = 3;
        Parameters:
        value - The bytes for messageId to set.
        Returns:
        This builder for chaining.
      • hasPublishTime

        public boolean hasPublishTime()
         The time at which the message was published, populated by the server when
         it receives the `Publish` call. It must not be populated by the
         publisher in a `Publish` call.
         
        .google.protobuf.Timestamp publish_time = 4;
        Specified by:
        hasPublishTime in interface PubsubMessageOrBuilder
        Returns:
        Whether the publishTime field is set.
      • getPublishTime

        public com.google.protobuf.Timestamp getPublishTime()
         The time at which the message was published, populated by the server when
         it receives the `Publish` call. It must not be populated by the
         publisher in a `Publish` call.
         
        .google.protobuf.Timestamp publish_time = 4;
        Specified by:
        getPublishTime in interface PubsubMessageOrBuilder
        Returns:
        The publishTime.
      • setPublishTime

        public PubsubMessage.Builder setPublishTime​(com.google.protobuf.Timestamp value)
         The time at which the message was published, populated by the server when
         it receives the `Publish` call. It must not be populated by the
         publisher in a `Publish` call.
         
        .google.protobuf.Timestamp publish_time = 4;
      • setPublishTime

        public PubsubMessage.Builder setPublishTime​(com.google.protobuf.Timestamp.Builder builderForValue)
         The time at which the message was published, populated by the server when
         it receives the `Publish` call. It must not be populated by the
         publisher in a `Publish` call.
         
        .google.protobuf.Timestamp publish_time = 4;
      • mergePublishTime

        public PubsubMessage.Builder mergePublishTime​(com.google.protobuf.Timestamp value)
         The time at which the message was published, populated by the server when
         it receives the `Publish` call. It must not be populated by the
         publisher in a `Publish` call.
         
        .google.protobuf.Timestamp publish_time = 4;
      • clearPublishTime

        public PubsubMessage.Builder clearPublishTime()
         The time at which the message was published, populated by the server when
         it receives the `Publish` call. It must not be populated by the
         publisher in a `Publish` call.
         
        .google.protobuf.Timestamp publish_time = 4;
      • getPublishTimeBuilder

        public com.google.protobuf.Timestamp.Builder getPublishTimeBuilder()
         The time at which the message was published, populated by the server when
         it receives the `Publish` call. It must not be populated by the
         publisher in a `Publish` call.
         
        .google.protobuf.Timestamp publish_time = 4;
      • getPublishTimeOrBuilder

        public com.google.protobuf.TimestampOrBuilder getPublishTimeOrBuilder()
         The time at which the message was published, populated by the server when
         it receives the `Publish` call. It must not be populated by the
         publisher in a `Publish` call.
         
        .google.protobuf.Timestamp publish_time = 4;
        Specified by:
        getPublishTimeOrBuilder in interface PubsubMessageOrBuilder
      • getOrderingKey

        public String getOrderingKey()
         If non-empty, identifies related messages for which publish order should be
         respected. If a `Subscription` has `enable_message_ordering` set to `true`,
         messages published with the same non-empty `ordering_key` value will be
         delivered to subscribers in the order in which they are received by the
         Pub/Sub system. All `PubsubMessage`s published in a given `PublishRequest`
         must specify the same `ordering_key` value.
         For more information, see [ordering
         messages](https://cloud.google.com/pubsub/docs/ordering).
         
        string ordering_key = 5;
        Specified by:
        getOrderingKey in interface PubsubMessageOrBuilder
        Returns:
        The orderingKey.
      • getOrderingKeyBytes

        public com.google.protobuf.ByteString getOrderingKeyBytes()
         If non-empty, identifies related messages for which publish order should be
         respected. If a `Subscription` has `enable_message_ordering` set to `true`,
         messages published with the same non-empty `ordering_key` value will be
         delivered to subscribers in the order in which they are received by the
         Pub/Sub system. All `PubsubMessage`s published in a given `PublishRequest`
         must specify the same `ordering_key` value.
         For more information, see [ordering
         messages](https://cloud.google.com/pubsub/docs/ordering).
         
        string ordering_key = 5;
        Specified by:
        getOrderingKeyBytes in interface PubsubMessageOrBuilder
        Returns:
        The bytes for orderingKey.
      • setOrderingKey

        public PubsubMessage.Builder setOrderingKey​(String value)
         If non-empty, identifies related messages for which publish order should be
         respected. If a `Subscription` has `enable_message_ordering` set to `true`,
         messages published with the same non-empty `ordering_key` value will be
         delivered to subscribers in the order in which they are received by the
         Pub/Sub system. All `PubsubMessage`s published in a given `PublishRequest`
         must specify the same `ordering_key` value.
         For more information, see [ordering
         messages](https://cloud.google.com/pubsub/docs/ordering).
         
        string ordering_key = 5;
        Parameters:
        value - The orderingKey to set.
        Returns:
        This builder for chaining.
      • clearOrderingKey

        public PubsubMessage.Builder clearOrderingKey()
         If non-empty, identifies related messages for which publish order should be
         respected. If a `Subscription` has `enable_message_ordering` set to `true`,
         messages published with the same non-empty `ordering_key` value will be
         delivered to subscribers in the order in which they are received by the
         Pub/Sub system. All `PubsubMessage`s published in a given `PublishRequest`
         must specify the same `ordering_key` value.
         For more information, see [ordering
         messages](https://cloud.google.com/pubsub/docs/ordering).
         
        string ordering_key = 5;
        Returns:
        This builder for chaining.
      • setOrderingKeyBytes

        public PubsubMessage.Builder setOrderingKeyBytes​(com.google.protobuf.ByteString value)
         If non-empty, identifies related messages for which publish order should be
         respected. If a `Subscription` has `enable_message_ordering` set to `true`,
         messages published with the same non-empty `ordering_key` value will be
         delivered to subscribers in the order in which they are received by the
         Pub/Sub system. All `PubsubMessage`s published in a given `PublishRequest`
         must specify the same `ordering_key` value.
         For more information, see [ordering
         messages](https://cloud.google.com/pubsub/docs/ordering).
         
        string ordering_key = 5;
        Parameters:
        value - The bytes for orderingKey to set.
        Returns:
        This builder for chaining.
      • setUnknownFields

        public final PubsubMessage.Builder setUnknownFields​(com.google.protobuf.UnknownFieldSet unknownFields)
        Specified by:
        setUnknownFields in interface com.google.protobuf.Message.Builder
        Overrides:
        setUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>
      • mergeUnknownFields

        public final PubsubMessage.Builder mergeUnknownFields​(com.google.protobuf.UnknownFieldSet unknownFields)
        Specified by:
        mergeUnknownFields in interface com.google.protobuf.Message.Builder
        Overrides:
        mergeUnknownFields in class com.google.protobuf.GeneratedMessageV3.Builder<PubsubMessage.Builder>