]> git.basschouten.com Git - openhab-addons.git/blob
cfeda7ddbacdc1106b8840d591eadf90782d5a8a
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.zoneminder.internal.handler;
14
15 import java.util.Date;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19
20 /**
21  * The {@link Event} represents the attributes of a Zoneminder event
22  * that are relevant to this binding.
23  *
24  * @author Mark Hilbush - Initial contribution
25  */
26 @NonNullByDefault
27 public class Event {
28
29     private String id;
30     private String name;
31     private String cause;
32     private String notes;
33     private Date start;
34     private Date end;
35     private int frames;
36     private int alarmFrames;
37     private double length;
38
39     public Event(String id, String name, String cause, String notes, Date start, Date end) {
40         this.id = id;
41         this.name = name;
42         this.cause = cause;
43         this.notes = notes;
44         this.start = start;
45         this.end = end;
46     }
47
48     public String getId() {
49         return id;
50     }
51
52     public String setId(String id) {
53         return this.id = id;
54     }
55
56     public String getName() {
57         return name;
58     }
59
60     public void setName(String name) {
61         this.name = name;
62     }
63
64     public String getCause() {
65         return cause;
66     }
67
68     public void setCause(String cause) {
69         this.cause = cause;
70     }
71
72     public String getNotes() {
73         return notes;
74     }
75
76     public void setNotes(String notes) {
77         this.notes = notes;
78     }
79
80     public Date getStart() {
81         return start;
82     }
83
84     public void setStart(Date start) {
85         this.start = start;
86     }
87
88     public Date getEnd() {
89         return end;
90     }
91
92     public void setEnd(Date end) {
93         this.end = end;
94     }
95
96     public int getFrames() {
97         return frames;
98     }
99
100     public void setFrames(@Nullable Integer frames) {
101         this.frames = frames != null ? frames : 0;
102     }
103
104     public int getAlarmFrames() {
105         return alarmFrames;
106     }
107
108     public void setAlarmFrames(@Nullable Integer alarmFrames) {
109         this.alarmFrames = alarmFrames != null ? alarmFrames : 0;
110     }
111
112     public double getLength() {
113         return length;
114     }
115
116     public void setLength(@Nullable Double length) {
117         this.length = length != null ? length : 0;
118     }
119
120     @Override
121     public String toString() {
122         StringBuffer sb = new StringBuffer();
123         sb.append("id=").append(id);
124         sb.append(", name=").append(name);
125         sb.append(", cause=").append(cause);
126         sb.append(", start=").append(start.toString());
127         sb.append(", end=").append(end.toString());
128         sb.append(", frames=").append(String.format("%d", frames));
129         sb.append(", alarmFrames=").append(String.format("%d", alarmFrames));
130         sb.append(", length=").append(String.format("%6.2", length));
131         sb.append(")");
132         return sb.toString();
133     }
134 }