]> git.basschouten.com Git - openhab-addons.git/blob
98fd07a0f7d8a381ad4e82be90febfb945f125f3
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.gardena.internal.model;
14
15 import java.util.Date;
16 import java.util.List;
17
18 import org.openhab.binding.gardena.internal.GardenaSmartCommandName;
19
20 import com.google.gson.annotations.SerializedName;
21
22 /**
23  * Represents a Gardena property.
24  *
25  * @author Gerhard Riegler - Initial contribution
26  */
27 public class Property {
28
29     private String name;
30     private PropertyValue value;
31     private Date timestamp;
32     private String unit;
33     private boolean writeable;
34
35     @SerializedName("supported_values")
36     private List<String> supportedValues;
37     private transient Ability ability;
38
39     public Property() {
40     }
41
42     public Property(GardenaSmartCommandName commandName, String value) {
43         this.name = commandName.toString().toLowerCase();
44         this.value = new PropertyValue(value);
45     }
46
47     /**
48      * Returns the name of the property.
49      */
50     public String getName() {
51         return name;
52     }
53
54     /**
55      * Returns the value of the property.
56      */
57     public String getValueAsString() {
58         return value != null ? value.getValue() : null;
59     }
60
61     /**
62      * Returns the value of the property.
63      */
64     public PropertyValue getValue() {
65         return value;
66     }
67
68     /**
69      * Sets the value of the property.
70      */
71     public void setValue(PropertyValue value) {
72         this.value = value;
73     }
74
75     /**
76      * Returns the timestamp of the property.
77      */
78     public Date getTimestamp() {
79         return timestamp;
80     }
81
82     /**
83      * Returns the unit of the property.
84      */
85     public String getUnit() {
86         return unit;
87     }
88
89     /**
90      * Returns true, if the property is writeable.
91      */
92     public boolean isWriteable() {
93         return writeable;
94     }
95
96     /**
97      * Returns a list of supported values.
98      */
99     public List<String> getSupportedValues() {
100         return supportedValues;
101     }
102
103     /**
104      * Returns the ability of the property.
105      */
106
107     public Ability getAbility() {
108         return ability;
109     }
110
111     /**
112      * Sets the ability of the property.
113      */
114     public void setAbility(Ability ability) {
115         this.ability = ability;
116     }
117 }