public final class ResolvedTopicIndex extends java.lang.Object implements KnowledgeIndex
TopicBinding
s 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());
TopicBinding
Constructor and Description |
---|
ResolvedTopicIndex(Model model) |
Modifier and Type | Method and Description |
---|---|
java.util.List<TopicBinding<? extends Trait>> |
getOperationBindings(ToShapeId operation)
Get all of the MQTT topic bindings of a specific operation.
|
java.util.Optional<TopicBinding<PublishTrait>> |
getPublishBinding(ToShapeId operation)
Gets the MQTT publish binding of an operation.
|
java.util.Optional<EventStreamInfo> |
getSubcribeEventStreamInfo(ToShapeId operation)
Get subscribe event stream info.
|
java.util.Optional<TopicBinding<SubscribeTrait>> |
getSubscribeBinding(ToShapeId operation)
Gets the MQTT subscribe binding of an operation.
|
static ResolvedTopicIndex |
of(Model model) |
java.util.stream.Stream<TopicBinding<? extends Trait>> |
topicBindings()
Gets all resolved MQTT topic bindings in the model.
|
public ResolvedTopicIndex(Model model)
public static ResolvedTopicIndex of(Model model)
public java.util.List<TopicBinding<? extends Trait>> getOperationBindings(ToShapeId operation)
operation
- Operation that has MQTT bindings.public java.util.stream.Stream<TopicBinding<? extends Trait>> topicBindings()
public java.util.Optional<TopicBinding<PublishTrait>> getPublishBinding(ToShapeId operation)
operation
- Operation that has MQTT bindings.public java.util.Optional<TopicBinding<SubscribeTrait>> getSubscribeBinding(ToShapeId operation)
operation
- Operation that has MQTT bindings.public java.util.Optional<EventStreamInfo> getSubcribeEventStreamInfo(ToShapeId operation)
This information describes if the event stream contains a single event, multiple events, and if there are any initial-request or response members.
operation
- Operation to get the event stream info o.