]> git.basschouten.com Git - openhab-addons.git/blob
338d8154e35d6caebb709eb763701d2b19e13d40
[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.boschshc.internal.services.userstate.dto;
14
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.openhab.binding.boschshc.internal.services.dto.BoschSHCServiceState;
17 import org.openhab.core.library.types.OnOffType;
18
19 /**
20  * Represents the state of a user-defined state
21  *
22  * @author Patrick Gell - Initial contribution
23  */
24 public class UserStateServiceState extends BoschSHCServiceState {
25
26     public UserStateServiceState() {
27         super("userdefinedstates");
28     }
29
30     /**
31      * Current state
32      */
33     private boolean state;
34
35     public boolean isState() {
36         return state;
37     }
38
39     public void setState(boolean state) {
40         this.state = state;
41     }
42
43     public void setStateFromString(final String stateStr) {
44         this.state = Boolean.parseBoolean(stateStr);
45     }
46
47     public String getStateAsString() {
48         return Boolean.toString(state);
49     }
50
51     public @NonNull OnOffType toOnOffType() {
52         return OnOffType.from(state);
53     }
54
55     @Override
56     public String toString() {
57         return "UserStateServiceState{" + "state=" + state + ", type='" + type + '\'' + '}';
58     }
59 }