2 * Copyright (c) 2010-2021 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.api.responses;
15 import java.time.DayOfWeek;
16 import java.util.EnumSet;
17 import java.util.List;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
23 * State of all Scheduled Events in an HD PowerView hub
25 * @author Jacob Laursen - Initial contribution
28 public class ScheduledEvents {
30 public static final EnumSet<DayOfWeek> WEEKDAYS = EnumSet.of(DayOfWeek.MONDAY, DayOfWeek.TUESDAY,
31 DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY);
33 public static final EnumSet<DayOfWeek> WEEKENDS = EnumSet.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY);
35 public static final int SCHEDULED_EVENT_TYPE_TIME = 0;
36 public static final int SCHEDULED_EVENT_TYPE_SUNRISE = 1;
37 public static final int SCHEDULED_EVENT_TYPE_SUNSET = 2;
39 public @Nullable List<ScheduledEvent> scheduledEventData;
40 public @Nullable List<Integer> scheduledEventIds;
43 * the following SuppressWarnings annotation is because the Eclipse compiler
44 * does NOT expect a NonNullByDefault annotation on the inner class, since it is
45 * implicitly inherited from the outer class, whereas the Maven compiler always
46 * requires an explicit NonNullByDefault annotation on all classes
48 @SuppressWarnings("null")
50 public static class ScheduledEvent {
52 public boolean enabled;
54 public int sceneCollectionId;
55 public boolean daySunday;
56 public boolean dayMonday;
57 public boolean dayTuesday;
58 public boolean dayWednesday;
59 public boolean dayThursday;
60 public boolean dayFriday;
61 public boolean daySaturday;
67 public boolean equals(@Nullable Object o) {
71 if (!(o instanceof ScheduledEvent)) {
74 ScheduledEvent other = (ScheduledEvent) o;
76 return this.id == other.id && this.enabled == other.enabled && this.sceneId == other.sceneId
77 && this.sceneCollectionId == other.sceneCollectionId && this.daySunday == other.daySunday
78 && this.dayMonday == other.dayMonday && this.dayTuesday == other.dayTuesday
79 && this.dayWednesday == other.dayWednesday && this.dayThursday == other.dayThursday
80 && this.dayFriday == other.dayFriday && this.daySaturday == other.daySaturday
81 && this.eventType == other.eventType && this.hour == other.hour && this.minute == other.minute;
85 public final int hashCode() {
88 result = prime * result + id;
89 result = prime * result + (enabled ? 1 : 0);
90 result = prime * result + sceneId;
91 result = prime * result + sceneCollectionId;
92 result = prime * result + (daySunday ? 1 : 0);
93 result = prime * result + (dayMonday ? 1 : 0);
94 result = prime * result + (dayTuesday ? 1 : 0);
95 result = prime * result + (dayWednesday ? 1 : 0);
96 result = prime * result + (dayThursday ? 1 : 0);
97 result = prime * result + (dayFriday ? 1 : 0);
98 result = prime * result + (daySaturday ? 1 : 0);
99 result = prime * result + eventType;
100 result = prime * result + hour;
101 result = prime * result + minute;
106 public EnumSet<DayOfWeek> getDays() {
107 EnumSet<DayOfWeek> days = EnumSet.noneOf(DayOfWeek.class);
109 days.add(DayOfWeek.SUNDAY);
112 days.add(DayOfWeek.MONDAY);
115 days.add(DayOfWeek.TUESDAY);
118 days.add(DayOfWeek.WEDNESDAY);
121 days.add(DayOfWeek.THURSDAY);
124 days.add(DayOfWeek.FRIDAY);
127 days.add(DayOfWeek.SATURDAY);