]> git.basschouten.com Git - openhab-addons.git/blob
1c74334e179746cd4c76bb6dd1950e33161fefd2
[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  * If the MQTT topic value needs to be transformed first before assigned to a field,
23  * annotate that field with this annotation.
24  *
25  * <p>
26  * Example: Two MQTT topics are "my-example/testname" with value "abc" and "my-example/values" with value "abc,def". The
27  * corresponding attribute class looks like this:
28  * </p>
29  *
30  * <pre>
31  * class MyExample extends AbstractMqttAttributeClass {
32  *     enum Testnames {
33  *         abc_
34  *     };
35  *
36  *     &#64;MapToField(suffix = "_")
37  *     Testnames testname;
38  *
39  *     &#64;MapToField(splitCharacter = ",")
40  *     String[] values;
41  * }
42  * </pre>
43  *
44  * @author David Graeff - Initial contribution
45  */
46 @Retention(RetentionPolicy.RUNTIME)
47 @Target(FIELD)
48 public @interface MQTTvalueTransform {
49     String suffix() default "";
50
51     String prefix() default "";
52
53     String splitCharacter() default "";
54 }