]> git.basschouten.com Git - openhab-addons.git/blob
f93c80e99318078f63d5d055b8ad2ab742130ccc
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.mqtt.generic.mapping;
14
15 import static java.lang.annotation.ElementType.FIELD;
16
17 import java.lang.annotation.Retention;
18 import java.lang.annotation.RetentionPolicy;
19 import java.lang.annotation.Target;
20
21 /**
22  * Annotate an attribute class field to mark it as required. If a required topic value cannot be received
23  * within a given timeframe, the entire attribute classes
24  * {@link AbstractMqttAttributeClass#subscribeAndReceive(org.openhab.core.io.transport.mqtt.MqttBrokerConnection, java.util.concurrent.ScheduledExecutorService, String, org.openhab.binding.mqtt.generic.internal.mapping.AbstractMqttAttributeClass.AttributeChanged, int)}
25  * call will fail.
26  *
27  * <p>
28  * Example: The MQTT topic is "my-example/name". The corresponding attribute class looks like this:
29  * </p>
30  *
31  * <pre>
32
33  * class MyExample extends AbstractMqttAttributeClass {
34  * * &#64;MandatoryField
35  *     String name;
36  * }
37  * </pre>
38  *
39  * @author David Graeff - Initial contribution
40  */
41 @Retention(RetentionPolicy.RUNTIME)
42 @Target({ FIELD })
43 public @interface MandatoryField {
44     boolean value() default true;
45 }