]> git.basschouten.com Git - openhab-addons.git/blob
c96ab1af0a355a15097e7797acbf42b9afd54e71
[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.lifx.internal.dto;
14
15 import java.time.Duration;
16
17 /**
18  * The pending or current HEV cycle state.
19  *
20  * @author Wouter Born - Initial contribution
21  */
22 public class HevCycleState {
23
24     public static final HevCycleState OFF = new HevCycleState(false);
25     public static final HevCycleState ON = new HevCycleState(true);
26
27     private boolean enable;
28     private Duration duration;
29
30     public HevCycleState(boolean enable) {
31         this.enable = enable;
32         this.duration = Duration.ZERO;
33     }
34
35     public HevCycleState(boolean enable, Duration duration) {
36         this.enable = enable;
37         this.duration = duration;
38     }
39
40     public boolean isEnable() {
41         return enable;
42     }
43
44     public Duration getDuration() {
45         return duration;
46     }
47
48     @Override
49     public int hashCode() {
50         final int prime = 31;
51         int result = 1;
52         result = prime * result + ((duration == null) ? 0 : duration.hashCode());
53         result = prime * result + (enable ? 1231 : 1237);
54         return result;
55     }
56
57     @Override
58     public boolean equals(Object obj) {
59         if (this == obj) {
60             return true;
61         }
62         if (obj == null) {
63             return false;
64         }
65         if (getClass() != obj.getClass()) {
66             return false;
67         }
68         HevCycleState other = (HevCycleState) obj;
69         if (duration == null) {
70             if (other.duration != null) {
71                 return false;
72             }
73         } else if (!duration.equals(other.duration)) {
74             return false;
75         }
76         return enable == other.enable;
77     }
78
79     @Override
80     public String toString() {
81         return "HevCycleState [enable=" + enable + ", duration=" + duration + "]";
82     }
83 }