2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.hdpowerview.internal.dto;
15 import java.time.DayOfWeek;
16 import java.util.EnumSet;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
22 * State of a single Scheduled Event, as returned by an HD PowerView Hub
24 * @author Jacob Laursen - Initial contribution
27 public class ScheduledEvent {
28 public static final EnumSet<DayOfWeek> WEEKDAYS = EnumSet.of(DayOfWeek.MONDAY, DayOfWeek.TUESDAY,
29 DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY);
31 public static final EnumSet<DayOfWeek> WEEKENDS = EnumSet.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY);
33 public static final int SCHEDULED_EVENT_TYPE_TIME = 0;
34 public static final int SCHEDULED_EVENT_TYPE_SUNRISE = 1;
35 public static final int SCHEDULED_EVENT_TYPE_SUNSET = 2;
38 public boolean enabled;
40 public int sceneCollectionId;
41 public boolean daySunday;
42 public boolean dayMonday;
43 public boolean dayTuesday;
44 public boolean dayWednesday;
45 public boolean dayThursday;
46 public boolean dayFriday;
47 public boolean daySaturday;
53 public boolean equals(@Nullable Object o) {
57 if (!(o instanceof ScheduledEvent)) {
60 ScheduledEvent other = (ScheduledEvent) o;
62 return this.id == other.id && this.enabled == other.enabled && this.sceneId == other.sceneId
63 && this.sceneCollectionId == other.sceneCollectionId && this.daySunday == other.daySunday
64 && this.dayMonday == other.dayMonday && this.dayTuesday == other.dayTuesday
65 && this.dayWednesday == other.dayWednesday && this.dayThursday == other.dayThursday
66 && this.dayFriday == other.dayFriday && this.daySaturday == other.daySaturday
67 && this.eventType == other.eventType && this.hour == other.hour && this.minute == other.minute;
71 public final int hashCode() {
74 result = prime * result + id;
75 result = prime * result + (enabled ? 1 : 0);
76 result = prime * result + sceneId;
77 result = prime * result + sceneCollectionId;
78 result = prime * result + (daySunday ? 1 : 0);
79 result = prime * result + (dayMonday ? 1 : 0);
80 result = prime * result + (dayTuesday ? 1 : 0);
81 result = prime * result + (dayWednesday ? 1 : 0);
82 result = prime * result + (dayThursday ? 1 : 0);
83 result = prime * result + (dayFriday ? 1 : 0);
84 result = prime * result + (daySaturday ? 1 : 0);
85 result = prime * result + eventType;
86 result = prime * result + hour;
87 result = prime * result + minute;
92 public EnumSet<DayOfWeek> getDays() {
93 EnumSet<DayOfWeek> days = EnumSet.noneOf(DayOfWeek.class);
95 days.add(DayOfWeek.SUNDAY);
98 days.add(DayOfWeek.MONDAY);
101 days.add(DayOfWeek.TUESDAY);
104 days.add(DayOfWeek.WEDNESDAY);
107 days.add(DayOfWeek.THURSDAY);
110 days.add(DayOfWeek.FRIDAY);
113 days.add(DayOfWeek.SATURDAY);