]> git.basschouten.com Git - openhab-addons.git/blob
9c09412ffc8a87ded9da1fc39a9176a2fd526911
[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.velux.internal.things;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * <B>Velux</B> product characteristics: Product State.
19  * <P>
20  * Combined set of information which describes a current state of a single Velux product.
21  * </P>
22  * Methods in handle this type of information:
23  * <UL>
24  * <LI>{@link #VeluxProductState(VeluxProductReference, int, int)} to create a new product state.</LI>
25  * <LI>{@link #getActuator()} to retrieve the number representing this actuator/product.</LI>
26  * <LI>{@link #getProductReference()} to retrieve reference to a product.</LI>
27  * <LI>{@link #getState()} to retrieve the current {@link VeluxProductState.ProductState product state}.</LI>
28  * <LI>{@link #getStateAsInt()} to retrieve the current product state.</LI>
29  * <LI>{@link #toString} to retrieve a human-readable description of the product state.</LI>
30  * </UL>
31  *
32  *
33  * @author Guenther Schreiner - initial contribution.
34  */
35 @NonNullByDefault
36 public class VeluxProductState {
37
38     // Type definitions
39
40     @NonNullByDefault
41     private class ProductState {
42
43         private int state;
44
45         public int getState() {
46             return state;
47         }
48
49         private ProductState(int state) {
50             this.state = state;
51         }
52     }
53
54     // Class internal
55
56     private VeluxProductReference productReference;
57     private int actuator;
58     private ProductState state;
59
60     // Constructor
61
62     public VeluxProductState(VeluxProductReference productReference, int actuator, int state) {
63         this.productReference = productReference;
64         this.actuator = actuator;
65         this.state = new ProductState(state);
66     }
67
68     // Class access methods
69
70     public VeluxProductReference getProductReference() {
71         return this.productReference;
72     }
73
74     public int getActuator() {
75         return this.actuator;
76     }
77
78     public ProductState getState() {
79         return this.state;
80     }
81
82     public int getStateAsInt() {
83         return this.state.getState();
84     }
85
86     @Override
87     public String toString() {
88         return String.format("State (%s, actuator %d, value %d)", this.productReference, this.actuator, this.state);
89     }
90 }