Interface MqttTopicFilter

All Superinterfaces:
Comparable<MqttUtf8String>, MqttUtf8String
All Known Subinterfaces:
MqttSharedTopicFilter

@DoNotImplement public interface MqttTopicFilter extends MqttUtf8String
MQTT Topic Filter according to the MQTT specification.

A Topic Filter has the same requirements as an UTF-8 encoded string. Additionally it

  • must be at least one character long,
  • may contain one multi-level wildcard character ('#') at the end and
  • may contain multiple single-level wildcards ('+').
Since:
1.0
  • Field Details

    • MULTI_LEVEL_WILDCARD

      static final char MULTI_LEVEL_WILDCARD
      The multi-level wildcard character.
      See Also:
    • SINGLE_LEVEL_WILDCARD

      static final char SINGLE_LEVEL_WILDCARD
      The single-level wildcard character.
      See Also:
  • Method Details

    • of

      Validates and creates a Topic Filter of the given string.
      Parameters:
      string - the string representation of the Topic Filter.
      Returns:
      the created Topic Filter.
      Throws:
      IllegalArgumentException - if the string is not a valid Topic Filter.
    • builder

      Creates a builder for a Topic Filter.
      Returns:
      the created builder.
    • getLevels

      Returns:
      the levels of this Topic Filter.
    • containsWildcards

      boolean containsWildcards()
      Returns:
      whether this Topic Filter contains wildcards.
    • containsMultiLevelWildcard

      boolean containsMultiLevelWildcard()
      Returns:
      whether this Topic Filter contains a multi-level wildcard.
    • containsSingleLevelWildcard

      boolean containsSingleLevelWildcard()
      Returns:
      whether this Topic Filter contains one ore more single-level wildcards.
    • isShared

      boolean isShared()
      Returns:
      whether this Topic Filter is shared.
    • share

      Parameters:
      shareName - the string representation of the Share Name.
      Returns:
      a Shared Topic Filter which shares this Topic Filter with the given Share Name.
    • matches

      boolean matches(@NotNull @NotNull MqttTopic topic)
      Matches this Topic Filter with the given Topic Name.
      Parameters:
      topic - the Topic Name to match.
      Returns:
      true if this Topic Filter matches the Topic Name, otherwise false.
    • matches

      boolean matches(@NotNull @NotNull MqttTopicFilter topicFilter)
      Matches this Topic Filter with the given Topic Filter.
      Parameters:
      topicFilter - the Topic Filter to match.
      Returns:
      true if this Topic Filter matches the given Topic Filter, otherwise false.
    • extend

      Creates a builder for extending this Topic Filter.
      Returns:
      the created builder.