|
| 1 | +/* |
| 2 | + * Copyright (c) 2023. Smart Operating Block |
| 3 | + * |
| 4 | + * Use of this source code is governed by an MIT-style |
| 5 | + * license that can be found in the LICENSE file or at |
| 6 | + * https://opensource.org/licenses/MIT. |
| 7 | + */ |
| 8 | + |
| 9 | +package application.presenter.event.model.roomevent; |
| 10 | + |
| 11 | +import application.presenter.event.model.Event; |
| 12 | +import application.presenter.event.model.roomevent.payload.RoomEventPayload; |
| 13 | + |
| 14 | +/** |
| 15 | + * Room environment conditions update event. |
| 16 | + * In addition to a normal {@link application.presenter.event.model.Event} it has the roomId and the roomType to which |
| 17 | + * the event refers. |
| 18 | + * @param <E> the type of the event payload. |
| 19 | + */ |
| 20 | +public class RoomEvent<E extends RoomEventPayload> implements Event<E> { |
| 21 | + private final String key; |
| 22 | + private final String roomId; |
| 23 | + private final RoomTypePayload roomType; |
| 24 | + private final E data; |
| 25 | + private final String dateTime; |
| 26 | + |
| 27 | + /** |
| 28 | + * Default constructor. |
| 29 | + * @param key the key of the event. |
| 30 | + * @param roomId the room identification to which the event is related to. |
| 31 | + * @param roomType the room type to which the event is related to. |
| 32 | + * @param data the payload. |
| 33 | + * @param dateTime the date time of the event. |
| 34 | + */ |
| 35 | + public RoomEvent( |
| 36 | + final String key, |
| 37 | + final String roomId, |
| 38 | + final RoomTypePayload roomType, |
| 39 | + final E data, |
| 40 | + final String dateTime |
| 41 | + ) { |
| 42 | + this.key = key; |
| 43 | + this.roomId = roomId; |
| 44 | + this.roomType = roomType; |
| 45 | + this.data = data; |
| 46 | + this.dateTime = dateTime; |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + public final String getKey() { |
| 51 | + return this.key; |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Obtain the room id to which the event is related to. |
| 56 | + * @return the room id. |
| 57 | + */ |
| 58 | + public String getRoomId() { |
| 59 | + return this.roomId; |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * Obtain the room type to which the event is related to. |
| 64 | + * @return the room type. |
| 65 | + */ |
| 66 | + public RoomTypePayload getRoomType() { |
| 67 | + return this.roomType; |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public final E getData() { |
| 72 | + return this.data; |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public final String getDateTime() { |
| 77 | + return this.dateTime; |
| 78 | + } |
| 79 | +} |
0 commit comments