Class SubscribePacket.SubscribePacketBuilder

  • Enclosing class:
    SubscribePacket

    public static final class SubscribePacket.SubscribePacketBuilder
    extends java.lang.Object
    A class to that allows for the creation of a SubscribePacket. Set all of the settings you want in the packet and then use the build() function to get a SubscribePacket populated with the settings defined in the builder.
    • Constructor Detail

      • SubscribePacketBuilder

        public SubscribePacketBuilder()
        Creates a new SubscribePacketBuilder so a SubscribePacket can be created.
    • Method Detail

      • withSubscription

        public SubscribePacket.SubscribePacketBuilder withSubscription​(SubscribePacket.Subscription subscription)
        Sets a single subscription within the SubscribePacket.
        Parameters:
        subscription - The subscription to add within the SubscribePacket.
        Returns:
        The SubscribePacketBuilder after setting the subscription.
      • withSubscription

        public SubscribePacket.SubscribePacketBuilder withSubscription​(java.lang.String topicFilter,
                                                                       QOS qos,
                                                                       java.lang.Boolean noLocal,
                                                                       java.lang.Boolean retainAsPublished,
                                                                       SubscribePacket.RetainHandlingType retainHandlingType)
        Sets a single subscription within the SubscribePacket.
        Parameters:
        topicFilter - The topic filter to subscribe to
        qos - The maximum QoS on which the subscriber will accept publish messages
        noLocal - Whether the server will not send publishes to a client when that client was the one who sent the publish
        retainAsPublished - Whether messages sent due to this subscription keep the retain flag preserved on the message
        retainHandlingType - Whether retained messages on matching topics be sent in reaction to this subscription
        Returns:
        The SubscribePacketBuilder after setting the subscription.
      • withSubscription

        public SubscribePacket.SubscribePacketBuilder withSubscription​(java.lang.String topicFilter,
                                                                       QOS qos)
        Sets a single subscription within the SubscribePacket.
        Parameters:
        topicFilter - The topic filter to subscribe to
        qos - The maximum QoS on which the subscriber will accept publish messages
        Returns:
        The SubscribePacketBuilder after setting the subscription.
      • withSubscriptionIdentifier

        public SubscribePacket.SubscribePacketBuilder withSubscriptionIdentifier​(long subscriptionIdentifier)
        Sets the positive long to associate with all topic filters in this request. Publish packets that match a subscription in this request should include this identifier in the resulting message. See MQTT5 Subscription Identifier
        Parameters:
        subscriptionIdentifier - A positive long to associate with all topic filters in this request.
        Returns:
        The SubscribePacketBuilder after setting the subscription identifier.
      • withUserProperties

        public SubscribePacket.SubscribePacketBuilder withUserProperties​(java.util.List<UserProperty> userProperties)
        Sets the list of MQTT5 user properties included with the packet. See MQTT5 User Property
        Parameters:
        userProperties - List of MQTT5 user properties to be included with the packet.
        Returns:
        The SubscribePacketBuilder after setting the user properties.
      • build

        public SubscribePacket build()
        Creates a new SUBSCRIBE packet using the settings set in the builder.
        Returns:
        The SubscribePacket created from the builder