Package com.plccom.mqtt.client
Class PlccomMqttLastWill.Builder
- java.lang.Object
-
- com.plccom.mqtt.client.PlccomMqttLastWill.Builder
-
- Enclosing class:
- PlccomMqttLastWill
public static final class PlccomMqttLastWill.Builder extends Object
Builder for immutable Last Will configuration.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlccomMqttLastWillbuild()Builds immutable Last Will configuration.PlccomMqttLastWill.BuildercontentType(String value)Sets the MQTT 5 Will Content Type property.PlccomMqttLastWill.BuildercorrelationData(byte[] value)Sets the MQTT 5 Will Correlation Data property.PlccomMqttLastWill.BuilderlastWillPayload(byte[] value)Sets the Last Will payload bytes.PlccomMqttLastWill.BuilderlastWillPayload(String value)Sets the Last Will payload from text.PlccomMqttLastWill.BuildermessageExpiryIntervalSeconds(Long value)Sets the MQTT 5 Will Message Expiry Interval property.PlccomMqttLastWill.BuilderpayloadFormatBytes()Declares the Last Will payload as unspecified binary data.PlccomMqttLastWill.BuilderpayloadFormatUtf8()Declares the Last Will payload as UTF-8 character data.PlccomMqttLastWill.BuilderpayloadFormatUtf8(Boolean value)Sets the MQTT 5 Will Payload Format Indicator property.PlccomMqttLastWill.BuilderqualityOfService(PlccomMqttQualityOfService value)Sets the requested Last Will QoS.PlccomMqttLastWill.BuilderresponseTopic(String value)Sets the MQTT 5 Will Response Topic property.PlccomMqttLastWill.Builderretain(boolean value)Sets the Last Will retain flag.PlccomMqttLastWill.BuilderuserProperties(List<PlccomMqttUserProperty> values)Replaces the MQTT 5 Will User Properties.PlccomMqttLastWill.BuilderuserProperty(String name, String value)Adds one MQTT 5 Will User Property.PlccomMqttLastWill.BuilderwillDelayIntervalSeconds(Long value)Sets the MQTT 5 Will Delay Interval property.
-
-
-
Method Detail
-
lastWillPayload
public PlccomMqttLastWill.Builder lastWillPayload(byte[] value)
Sets the Last Will payload bytes.- Parameters:
value- payload bytes, ornullto use an empty payload- Returns:
- this builder
-
lastWillPayload
public PlccomMqttLastWill.Builder lastWillPayload(String value)
Sets the Last Will payload from text.The text is encoded as UTF-8 bytes for MQTT transmission.
- Parameters:
value- payload text, ornullto use an empty payload- Returns:
- this builder
-
qualityOfService
public PlccomMqttLastWill.Builder qualityOfService(PlccomMqttQualityOfService value)
Sets the requested Last Will QoS.- Parameters:
value- requested QoS- Returns:
- this builder
- Throws:
NullPointerException- ifvalueisnull
-
retain
public PlccomMqttLastWill.Builder retain(boolean value)
Sets the Last Will retain flag.- Parameters:
value-trueto ask the broker to retain the Will- Returns:
- this builder
-
payloadFormatUtf8
public PlccomMqttLastWill.Builder payloadFormatUtf8(Boolean value)
Sets the MQTT 5 Will Payload Format Indicator property.- Parameters:
value-truefor UTF-8 character data,falsefor unspecified binary data, ornullto omit the property- Returns:
- this builder
-
payloadFormatUtf8
public PlccomMqttLastWill.Builder payloadFormatUtf8()
Declares the Last Will payload as UTF-8 character data.- Returns:
- this builder
-
payloadFormatBytes
public PlccomMqttLastWill.Builder payloadFormatBytes()
Declares the Last Will payload as unspecified binary data.- Returns:
- this builder
-
messageExpiryIntervalSeconds
public PlccomMqttLastWill.Builder messageExpiryIntervalSeconds(Long value)
Sets the MQTT 5 Will Message Expiry Interval property.- Parameters:
value- expiry interval in seconds, ornullto omit the property- Returns:
- this builder
- Throws:
IllegalArgumentException- ifvalueis outside the MQTT unsigned 32-bit range
-
willDelayIntervalSeconds
public PlccomMqttLastWill.Builder willDelayIntervalSeconds(Long value)
Sets the MQTT 5 Will Delay Interval property.- Parameters:
value- delay interval in seconds, ornullto omit the property- Returns:
- this builder
- Throws:
IllegalArgumentException- ifvalueis outside the MQTT unsigned 32-bit range
-
contentType
public PlccomMqttLastWill.Builder contentType(String value)
Sets the MQTT 5 Will Content Type property.- Parameters:
value- content type, ornullto omit the property- Returns:
- this builder
-
responseTopic
public PlccomMqttLastWill.Builder responseTopic(String value)
Sets the MQTT 5 Will Response Topic property.- Parameters:
value- response topic, ornullto omit the property- Returns:
- this builder
-
correlationData
public PlccomMqttLastWill.Builder correlationData(byte[] value)
Sets the MQTT 5 Will Correlation Data property.- Parameters:
value- correlation data bytes, ornullto omit the property- Returns:
- this builder
-
userProperty
public PlccomMqttLastWill.Builder userProperty(String name, String value)
Adds one MQTT 5 Will User Property.- Parameters:
name- property namevalue- property value- Returns:
- this builder
- Throws:
NullPointerException- ifnameorvalueisnull
-
userProperties
public PlccomMqttLastWill.Builder userProperties(List<PlccomMqttUserProperty> values)
Replaces the MQTT 5 Will User Properties.- Parameters:
values- user properties, ornullto clear the list- Returns:
- this builder
- Throws:
NullPointerException- ifvaluescontains anullelement
-
build
public PlccomMqttLastWill build()
Builds immutable Last Will configuration.- Returns:
- Last Will configuration
- Throws:
NullPointerException- if the topic or QoS isnullIllegalArgumentException- if the topic is empty
-
-