Class ResolvedTopicIndex
java.lang.Object
software.amazon.smithy.mqtt.traits.ResolvedTopicIndex
- All Implemented Interfaces:
software.amazon.smithy.model.knowledge.KnowledgeIndex
public final class ResolvedTopicIndex
extends Object
implements software.amazon.smithy.model.knowledge.KnowledgeIndex
Computes all of the MQTT
TopicBindings in a model.
This index is useful for things like finding the payload of an MQTT topic on an operation and grabbing the event stream information of a subscribe operation.
ResolvedTopicIndex resolvedIndex = ResolvedTopicIndex.of(model);
TopicBinding<PublishTrait> binding = resolvedIndex.getPublishBinding(myOperation).get();
assert(binding.getTopic() instanceOf Topic);
assert(binding.getMqttTrait() instanceOf PublishTrait);
System.out.println(binding.getPayloadShape());
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<TopicBinding<? extends software.amazon.smithy.model.traits.Trait>>getOperationBindings(software.amazon.smithy.model.shapes.ToShapeId operation) Get all of the MQTT topic bindings of a specific operation.getPublishBinding(software.amazon.smithy.model.shapes.ToShapeId operation) Gets the MQTT publish binding of an operation.Optional<software.amazon.smithy.model.knowledge.EventStreamInfo>getSubcribeEventStreamInfo(software.amazon.smithy.model.shapes.ToShapeId operation) Get subscribe event stream info.getSubscribeBinding(software.amazon.smithy.model.shapes.ToShapeId operation) Gets the MQTT subscribe binding of an operation.static ResolvedTopicIndexof(software.amazon.smithy.model.Model model) Stream<TopicBinding<? extends software.amazon.smithy.model.traits.Trait>>Gets all resolved MQTT topic bindings in the model.
-
Constructor Details
-
ResolvedTopicIndex
public ResolvedTopicIndex(software.amazon.smithy.model.Model model)
-
-
Method Details
-
of
-
getOperationBindings
public List<TopicBinding<? extends software.amazon.smithy.model.traits.Trait>> getOperationBindings(software.amazon.smithy.model.shapes.ToShapeId operation) Get all of the MQTT topic bindings of a specific operation.- Parameters:
operation- Operation that has MQTT bindings.- Returns:
- Returns the found MQTT bindings.
-
topicBindings
Gets all resolved MQTT topic bindings in the model.- Returns:
- Returns the stream of MQTT topic bindings in the model.
-
getPublishBinding
public Optional<TopicBinding<PublishTrait>> getPublishBinding(software.amazon.smithy.model.shapes.ToShapeId operation) Gets the MQTT publish binding of an operation.- Parameters:
operation- Operation that has MQTT bindings.- Returns:
- Returns the optionally found MQTT publish bindings.
-
getSubscribeBinding
public Optional<TopicBinding<SubscribeTrait>> getSubscribeBinding(software.amazon.smithy.model.shapes.ToShapeId operation) Gets the MQTT subscribe binding of an operation.- Parameters:
operation- Operation that has MQTT bindings.- Returns:
- Returns the optionally found MQTT subscribe bindings.
-
getSubcribeEventStreamInfo
public Optional<software.amazon.smithy.model.knowledge.EventStreamInfo> getSubcribeEventStreamInfo(software.amazon.smithy.model.shapes.ToShapeId operation) Get subscribe event stream info.This information describes if the event stream contains a single event, multiple events, and if there are any initial-request or response members.
- Parameters:
operation- Operation to get the event stream info o.- Returns:
- Returns the optionally found event stream info.
-