Interface RetainedPublishBuilder
-
@DoNotImplement public interface RetainedPublishBuilder
This builder must be used to create aRetainedPublish.Either from values, from a
PublishPacketor aPublish.Every RetainedPublish built by this builder is fully validated against HiveMQ configuration.
- Since:
- 4.0.0, CE 2019.1
-
-
Method Summary
-
-
-
Method Detail
-
fromPublish
@NotNull RetainedPublishBuilder fromPublish(@NotNull PublishPacket publishPacket)
Create aRetainedPublishfrom the values of aPublishPacket.- Parameters:
publishPacket- The publish packet to build aPublishfrom.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the publish packet is null.DoNotImplementException- If thePublishPacketis implemented by the extension.- Since:
- 4.0.0, CE 2019.1
-
fromPublish
@NotNull RetainedPublishBuilder fromPublish(@NotNull Publish publish)
Create aRetainedPublishfrom the values of aPublish.- Parameters:
publish- The publish to build aPublishfrom.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the publish is null.DoNotImplementException- If thePublishis implemented by the extension.- Since:
- 4.0.0, CE 2019.1
-
qos
@NotNull RetainedPublishBuilder qos(@NotNull Qos qos)
Sets the quality of service.DEFAULT:
QoS 0.- Parameters:
qos- TheQosto set.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the qos is null.IllegalArgumentException- If qos is higher than the maximum configured qos by HiveMQ. Default is QoS 2.- Since:
- 4.0.0, CE 2019.1
-
topic
@NotNull RetainedPublishBuilder topic(@NotNull String topic)
Sets the topic.This value has no default and must be set.
- Parameters:
topic- The topic to set.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the topic is null.IllegalArgumentException- If the topic is an empty string.IllegalArgumentException- If the topic is invalid for publish messages.IllegalArgumentException- If the topic length exceeds the configured length for topics. Default is 65535.- Since:
- 4.0.0, CE 2019.1
-
payloadFormatIndicator
@NotNull RetainedPublishBuilder payloadFormatIndicator(@Nullable PayloadFormatIndicator payloadFormatIndicator)
Sets the payload format indicator.DEFAULT:
null.- Parameters:
payloadFormatIndicator- The payload format indicator to set.- Returns:
- The
RetainedPublishBuilder. - Since:
- 4.0.0, CE 2019.1
-
messageExpiryInterval
@NotNull RetainedPublishBuilder messageExpiryInterval(long messageExpiryInterval)
Sets the message expiry interval in seconds.DEFAULT:
no expiry.The default can be changed by configuring
<message-expiry>in the<mqtt>config in the config.xml.- Parameters:
messageExpiryInterval- The message expiry interval to set.- Returns:
- The
RetainedPublishBuilder. - Throws:
IllegalArgumentException- If the message expiry interval is less than zero or more than the configured maximum by HiveMQ. Default is no expiry.- Since:
- 4.0.0, CE 2019.1
-
responseTopic
@NotNull RetainedPublishBuilder responseTopic(@Nullable String responseTopic)
Sets the response topic.DEFAULT:
null.- Parameters:
responseTopic- The response topic to set.- Returns:
- The
RetainedPublishBuilder. - Throws:
IllegalArgumentException- If the response topic is not a valid UTF-8 string.IllegalArgumentException- If the response topic exceeds the UTF-8 string length limit.- Since:
- 4.0.0, CE 2019.1
-
correlationData
@NotNull RetainedPublishBuilder correlationData(@Nullable ByteBuffer correlationData)
Sets the correlation data.DEFAULT:
null.- Parameters:
correlationData- The correlation data to set.- Returns:
- The
RetainedPublishBuilder. - Since:
- 4.0.0, CE 2019.1
-
contentType
@NotNull RetainedPublishBuilder contentType(@Nullable String contentType)
Sets the content type.DEFAULT:
null.- Parameters:
contentType- The content type to set.- Returns:
- The
RetainedPublishBuilder. - Throws:
IllegalArgumentException- If the content type is not a valid UTF-8 string.IllegalArgumentException- If the content type exceeds the UTF-8 string length limit.- Since:
- 4.0.0, CE 2019.1
-
payload
@NotNull RetainedPublishBuilder payload(@NotNull ByteBuffer payload)
Sets the payload.This value has no default and must be set.
- Parameters:
payload- The payload to set.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the payload is null.- Since:
- 4.0.0, CE 2019.1
-
userProperty
@NotNull RetainedPublishBuilder userProperty(@NotNull String key, @NotNull String value)
Adds a user property.DEFAULT:
empty list.- Parameters:
key- The key of the user property to add.value- The value of the user property to add.- Returns:
- The
RetainedPublishBuilder. - Throws:
NullPointerException- If the key or the value is null.IllegalArgumentException- If the key or value is not a valid UTF-8 string.IllegalArgumentException- If the key or value exceeds the UTF-8 string length limit.- Since:
- 4.0.0, CE 2019.1
-
build
@NotNull RetainedPublish build()
Builds theRetainedPublishwith the provided values or default values.- Returns:
- A
RetainedPublishwith the set parameters. - Throws:
NullPointerException- If the topic or the payload is null.- Since:
- 4.0.0, CE 2019.1
-
-