-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c615947
commit ec74ca5
Showing
3 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
src/main/java/software/amazon/awssdk/crt/iot/MqttRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package software.amazon.awssdk.crt.iot; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class MqttRequest { | ||
|
||
public static class MqttRequestBuilder { | ||
|
||
private MqttRequest request = new MqttRequest(); | ||
|
||
private MqttRequestBuilder() {} | ||
|
||
public MqttRequestBuilder withResponsePath(MqttRequestResponsePath path) { | ||
request.responsePaths.add(path); | ||
return this; | ||
} | ||
|
||
public MqttRequestBuilder withSubscription(String topicFilter) { | ||
request.subscriptions.add(topicFilter); | ||
return this; | ||
} | ||
|
||
public MqttRequestBuilder withPublishTopic(String publishTopic) { | ||
request.publishTopic = publishTopic; | ||
return this; | ||
} | ||
|
||
public MqttRequestBuilder withPayload(byte[] payload) { | ||
request.payload = payload; | ||
return this; | ||
} | ||
|
||
|
||
public MqttRequestBuilder withCorrelationToken(String correlationToken) { | ||
request.correlationToken = correlationToken; | ||
return this; | ||
} | ||
|
||
public MqttRequest build() { | ||
return new MqttRequest(request); | ||
} | ||
} | ||
|
||
private ArrayList<MqttRequestResponsePath> responsePaths = new ArrayList<>(); | ||
private ArrayList<String> subscriptions = new ArrayList<>(); | ||
private String publishTopic; | ||
private String correlationToken; | ||
private byte[] payload; | ||
|
||
private MqttRequest() { | ||
} | ||
|
||
private MqttRequest(MqttRequest request) { | ||
this.responsePaths.addAll(request.responsePaths); | ||
this.subscriptions.addAll(request.subscriptions); | ||
this.publishTopic = request.publishTopic; | ||
this.correlationToken = request.correlationToken; | ||
this.payload = request.payload; | ||
} | ||
|
||
public MqttRequestBuilder builder() { | ||
return new MqttRequestBuilder(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/software/amazon/awssdk/crt/iot/MqttRequestResponsePath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package software.amazon.awssdk.crt.iot; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class MqttRequestResponsePath { | ||
|
||
public static class MqttRequestResponsePathBuilder { | ||
|
||
private MqttRequestResponsePath path = new MqttRequestResponsePath(); | ||
|
||
private MqttRequestResponsePathBuilder() {} | ||
|
||
public MqttRequestResponsePathBuilder withResponseTopic(String responseTopic) { | ||
path.responseTopic = responseTopic; | ||
return this; | ||
} | ||
|
||
public MqttRequestResponsePathBuilder withCorrelationTokenJsonPath(String correlationTokenJsonpath) { | ||
path.correlationTokenJsonpath = correlationTokenJsonpath; | ||
return this; | ||
} | ||
|
||
public MqttRequestResponsePath build() { | ||
return new MqttRequestResponsePath(path); | ||
} | ||
} | ||
|
||
private String responseTopic; | ||
private String correlationTokenJsonpath; | ||
|
||
private MqttRequestResponsePath() { | ||
} | ||
|
||
private MqttRequestResponsePath(MqttRequestResponsePath path) { | ||
this.responseTopic = path.responseTopic; | ||
this.correlationTokenJsonpath = path.correlationTokenJsonpath; | ||
} | ||
|
||
public static MqttRequestResponsePathBuilder builder() { | ||
return new MqttRequestResponsePathBuilder(); | ||
} | ||
} |