Class TopicBinding<T extends software.amazon.smithy.model.traits.Trait>
Smithy models can contain a number of MQTT topics that are formed by
the publish and subscribe traits. Each of these
traits resolves to a single MQTT topic.
This class abstracts away the process of computing the payload of an MQTT operation. Each topic binding provides the following information:
- The operation in the model that created the binding.
- The MQTT topic.
- The payload shape that forms the payload of the topic.
- The optionally present input structure of the operation, which provides information like topic label bindings.
@smithy.mqtt#publish topics
Operations marked with@smithy.mqtt#publish resolve to a single topic that
is defined by topic property of the trait.
subscribe topics
Operations marked withsubscribe resolve to a single topic
that is defined by the topic property of the trait.
Payload resolution
The payload binding of a topic binding can be resolved to either no payload (e.g., publish operations with no input shape), a structure payload, or a member of a structure. The target of a specific event shape member can be used as a payload insubscribe
operations where an event member is marked with the eventPayload
trait.-
Method Summary
Modifier and TypeMethodDescriptionbooleanconflictsWith(TopicBinding<?> other) Returns true if the topic binding conflicts with another.booleanOptional<software.amazon.smithy.model.shapes.StructureShape>getInput()Deprecated.Use getInputShape instead.software.amazon.smithy.model.shapes.StructureShapeGets the input shape related to this operation.Gets the trait that formed the binding of the operation to MQTT for this topic.software.amazon.smithy.model.shapes.OperationShapeGets the operation shape related to the topic bindings.static Optional<? extends software.amazon.smithy.model.traits.Trait>getOperationMqttTrait(software.amazon.smithy.model.shapes.Shape operation) Finds the MQTT binding trait associated with an operation.Optional<software.amazon.smithy.model.shapes.Shape>Gets the payload shape of the topic.getTopic()Gets the resolved topic of the binding.inthashCode()toString()
-
Method Details
-
getOperationMqttTrait
public static Optional<? extends software.amazon.smithy.model.traits.Trait> getOperationMqttTrait(software.amazon.smithy.model.shapes.Shape operation) Finds the MQTT binding trait associated with an operation.- Parameters:
operation- Operation to check.- Returns:
- Returns the optionally found MQTT binding trait.
-
getMqttTrait
Gets the trait that formed the binding of the operation to MQTT for this topic.The provided trait will be either an instance of
PublishTraitorSubscribeTrait.- Returns:
- Returns the MQTT trait binding.
-
getOperation
public software.amazon.smithy.model.shapes.OperationShape getOperation()Gets the operation shape related to the topic bindings.- Returns:
- Returns the operation that has topic bindings.
-
getTopic
Gets the resolved topic of the binding.- Returns:
- Returns the resolved topic.
-
getInput
Deprecated.Use getInputShape instead.Gets the input shape related to this operation.- Returns:
- Returns the optional input shape.
-
getInputShape
public software.amazon.smithy.model.shapes.StructureShape getInputShape()Gets the input shape related to this operation.- Returns:
- Returns the input shape.
-
getPayloadShape
Gets the payload shape of the topic.The payload shape is either a structure for a single-event event stream, or a union for a multi-event event stream.
- Returns:
- Returns the optional payload target.
-
conflictsWith
Returns true if the topic binding conflicts with another.A topic binding is considered conflicting if both bindings have conflicting topics determined through
Topic.conflictsWith(software.amazon.smithy.mqtt.traits.Topic)and the topic bindings utilize a different payload. If both topics do not have a payload then they are not conflicting. If both topics have a payload, but they target the same shape, then they are not conflicting.- Parameters:
other- Other topic binding to compare against.- Returns:
- Returns true if the topic bindings conflict.
-
equals
-
hashCode
public int hashCode() -
toString
-