Class AsyncApiChannel

java.lang.Object
org.mockserver.async.asyncapi.AsyncApiChannel

public class AsyncApiChannel extends Object
Represents a single channel from an AsyncAPI specification, with its name, zero or more message payload examples, and optional publish-time bindings (MQTT qos/retain, Kafka key).
  • Constructor Details

    • AsyncApiChannel

      public AsyncApiChannel(String name, List<com.fasterxml.jackson.databind.JsonNode> payloadExamples, com.fasterxml.jackson.databind.JsonNode payloadSchema)
      Backward-compatible constructor — no bindings.
    • AsyncApiChannel

      public AsyncApiChannel(String name, List<com.fasterxml.jackson.databind.JsonNode> payloadExamples, com.fasterxml.jackson.databind.JsonNode payloadSchema, Integer mqttQos, Boolean mqttRetain, String kafkaKey)
      Full constructor with optional binding fields.
      Parameters:
      name - the channel / topic name
      payloadExamples - explicit payload examples from the spec
      payloadSchema - the JSON Schema for the payload (may be null)
      mqttQos - MQTT QoS level from operation bindings (may be null)
      mqttRetain - MQTT retain flag from operation bindings (may be null)
      kafkaKey - Kafka message key from message bindings (may be null)
    • AsyncApiChannel

      public AsyncApiChannel(String name, List<com.fasterxml.jackson.databind.JsonNode> payloadExamples, com.fasterxml.jackson.databind.JsonNode payloadSchema, Integer mqttQos, Boolean mqttRetain, String kafkaKey, List<AsyncApiMessage> explicitMessages)
      Full constructor with optional binding fields and explicit multi-message list.
      Parameters:
      name - the channel / topic name
      payloadExamples - explicit payload examples from the spec (first message's examples for back-compat)
      payloadSchema - the JSON Schema for the payload (first message's schema for back-compat)
      mqttQos - MQTT QoS level from operation bindings (may be null)
      mqttRetain - MQTT retain flag from operation bindings (may be null)
      kafkaKey - Kafka message key from first message's bindings (may be null)
      explicitMessages - the list of all messages in this channel (null or empty for single-message channels)
    • AsyncApiChannel

      public AsyncApiChannel(String name, List<com.fasterxml.jackson.databind.JsonNode> payloadExamples, com.fasterxml.jackson.databind.JsonNode payloadSchema, Integer mqttQos, Boolean mqttRetain, String kafkaKey, List<AsyncApiMessage> explicitMessages, String correlationIdLocation)
      Full constructor with optional binding fields, explicit multi-message list, and correlation ID location for single-message channels.
      Parameters:
      name - the channel / topic name
      payloadExamples - explicit payload examples from the spec (first message's examples for back-compat)
      payloadSchema - the JSON Schema for the payload (first message's schema for back-compat)
      mqttQos - MQTT QoS level from operation bindings (may be null)
      mqttRetain - MQTT retain flag from operation bindings (may be null)
      kafkaKey - Kafka message key from first message's bindings (may be null)
      explicitMessages - the list of all messages in this channel (null or empty for single-message channels)
      correlationIdLocation - correlation ID runtime expression for single-message channels (may be null)
  • Method Details

    • getName

      public String getName()
    • getPayloadExamples

      public List<com.fasterxml.jackson.databind.JsonNode> getPayloadExamples()
      Explicit examples found in the spec for the channel's message payload.
    • getPayloadSchema

      public com.fasterxml.jackson.databind.JsonNode getPayloadSchema()
      The JSON Schema describing the payload (may be null if not present).
    • getMqttQos

      public Integer getMqttQos()
      MQTT QoS level (0, 1, or 2) from operation-level bindings, or null if not specified.
    • getMqttRetain

      public Boolean getMqttRetain()
      MQTT retain flag from operation-level bindings, or null if not specified.
    • getKafkaKey

      public String getKafkaKey()
      Kafka message key from message-level bindings, or null if not derivable. Only populated when a literal value (const, example, examples[0]) is present.
    • getMessages

      public List<AsyncApiMessage> getMessages()
      Returns all messages for this channel as a uniform list.

      If this channel was parsed with multiple explicit messages (v3 multi-message or v2 oneOf), returns that list. Otherwise, synthesizes a single-element list from this channel's existing payload schema, examples, and kafka key fields, providing a uniform per-message view for both single- and multi-message channels.

      Returns:
      an unmodifiable list of at least one AsyncApiMessage
    • toPublishOptions

      public PublishOptions toPublishOptions()
      Build a PublishOptions from the parsed bindings on this channel.
      Returns:
      a PublishOptions carrying the binding values, or PublishOptions.none() when all are null