]> git.basschouten.com Git - openhab-addons.git/blob
1789baed437105339d503de1528f213ccabfdab1
[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.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     private class ProductState {
41
42         private int state;
43
44         public int getState() {
45             return state;
46         }
47
48         private ProductState(int state) {
49             this.state = state;
50         }
51     }
52
53     // Class internal
54
55     private VeluxProductReference productReference;
56     private int actuator;
57     private ProductState state;
58
59     // Constructor
60
61     public VeluxProductState(VeluxProductReference productReference, int actuator, int state) {
62         this.productReference = productReference;
63         this.actuator = actuator;
64         this.state = new ProductState(state);
65     }
66
67     // Class access methods
68
69     public VeluxProductReference getProductReference() {
70         return this.productReference;
71     }
72
73     public int getActuator() {
74         return this.actuator;
75     }
76
77     public ProductState getState() {
78         return this.state;
79     }
80
81     public int getStateAsInt() {
82         return this.state.getState();
83     }
84
85     @Override
86     public String toString() {
87         return String.format("State (%s, actuator %d, value %d)", this.productReference, this.actuator, this.state);
88     }
89 }