Line data Source code
1 : /*
2 : * Package : mqtt_client
3 : * Author : S. Hamblett <steve.hamblett@linux.com>
4 : * Date : 31/05/2017
5 : * Copyright : S.Hamblett
6 : */
7 :
8 : part of mqtt_client;
9 :
10 : /// Implementation of a Publication topic that performs additional validations
11 : /// of messages that are published.
12 : class PublicationTopic extends Topic {
13 : PublicationTopic(String topic)
14 8 : : super(topic, [
15 : Topic.validateMinLength,
16 : Topic.validateMaxLength,
17 : _validateWildcards
18 : ]);
19 :
20 : /// Validates that the topic has no wildcards which are not allowed in publication topics.
21 : static void _validateWildcards(Topic topicInstance) {
22 4 : if (topicInstance.hasWildcards) {
23 1 : throw new Exception(
24 : "mqtt_client::PublicationTopic: Cannot publish to a topic that contains MQTT topic wildcards (# or +)");
25 : }
26 : }
27 : }
|