You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ie...@apache.org on 2019/04/02 09:22:21 UTC
[beam] branch master updated: [BEAM-3312] Add builder methods to
MqttIO.ConnectionConfiguration
This is an automated email from the ASF dual-hosted git repository.
iemejia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 953a362 [BEAM-3312] Add builder methods to MqttIO.ConnectionConfiguration
new 51e50a8 Merge pull request #8167: [BEAM-6241[ Add builder methods to MqttIO.ConnectionConfiguration
953a362 is described below
commit 953a362c317eecf0a542e83a69aedd4095acd661
Author: EdgarLGB <lg...@outlook.com>
AuthorDate: Fri Mar 29 12:14:27 2019 +0100
[BEAM-3312] Add builder methods to MqttIO.ConnectionConfiguration
---
.../java/org/apache/beam/sdk/io/mqtt/MqttIO.java | 26 ++++++++++++++++------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/sdks/java/io/mqtt/src/main/java/org/apache/beam/sdk/io/mqtt/MqttIO.java b/sdks/java/io/mqtt/src/main/java/org/apache/beam/sdk/io/mqtt/MqttIO.java
index 111789b..797d702 100644
--- a/sdks/java/io/mqtt/src/main/java/org/apache/beam/sdk/io/mqtt/MqttIO.java
+++ b/sdks/java/io/mqtt/src/main/java/org/apache/beam/sdk/io/mqtt/MqttIO.java
@@ -121,10 +121,8 @@ public class MqttIO {
@AutoValue
public abstract static class ConnectionConfiguration implements Serializable {
- @Nullable
abstract String getServerUri();
- @Nullable
abstract String getTopic();
@Nullable
@@ -179,21 +177,35 @@ public class MqttIO {
* @return A connection configuration to the MQTT broker.
*/
public static ConnectionConfiguration create(String serverUri, String topic, String clientId) {
+ checkArgument(clientId != null, "clientId can not be null");
+ return create(serverUri, topic).withClientId(clientId);
+ }
+
+ /** Set up the MQTT broker URI. */
+ public ConnectionConfiguration withServerUri(String serverUri) {
checkArgument(serverUri != null, "serverUri can not be null");
+ return builder().setServerUri(serverUri).build();
+ }
+
+ /** Set up the MQTT getTopic pattern. */
+ public ConnectionConfiguration withTopic(String topic) {
checkArgument(topic != null, "topic can not be null");
+ return builder().setTopic(topic).build();
+ }
+
+ /** Set up the client ID prefix, which is used to construct an unique client ID. */
+ public ConnectionConfiguration withClientId(String clientId) {
checkArgument(clientId != null, "clientId can not be null");
- return new AutoValue_MqttIO_ConnectionConfiguration.Builder()
- .setServerUri(serverUri)
- .setTopic(topic)
- .setClientId(clientId)
- .build();
+ return builder().setClientId(clientId).build();
}
public ConnectionConfiguration withUsername(String username) {
+ checkArgument(username != null, "username can not be null");
return builder().setUsername(username).build();
}
public ConnectionConfiguration withPassword(String password) {
+ checkArgument(password != null, "password can not be null");
return builder().setPassword(password).build();
}