From ebfec5b9496b4690a9d8ecbb36d9b44e921c1bcd Mon Sep 17 00:00:00 2001 From: Andrea Acampora Date: Fri, 24 Mar 2023 11:27:04 +0100 Subject: [PATCH] chore: add model data for room entity --- src/main/kotlin/entity/room/Room.kt | 28 +++++++++++++++++++++++++ src/main/kotlin/entity/room/RoomData.kt | 27 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/main/kotlin/entity/room/Room.kt create mode 100644 src/main/kotlin/entity/room/RoomData.kt diff --git a/src/main/kotlin/entity/room/Room.kt b/src/main/kotlin/entity/room/Room.kt new file mode 100644 index 00000000..1f9d31e8 --- /dev/null +++ b/src/main/kotlin/entity/room/Room.kt @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023. Smart Operating Block + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + */ + +package entity.room + +/** The model of a Room of the Operating Block composed by: + * - the [id] of the room, + * - the [name] of the room, + * - the [type] of the room. + */ +data class Room( + val id: RoomData.RoomId, + val name: String?, + val type: RoomData.RoomType +) { + override fun equals(other: Any?): Boolean = when { + other === this -> true + other is Room -> this.id == other.id + else -> false + } + + override fun hashCode(): Int = this.id.hashCode() +} diff --git a/src/main/kotlin/entity/room/RoomData.kt b/src/main/kotlin/entity/room/RoomData.kt new file mode 100644 index 00000000..be858d1e --- /dev/null +++ b/src/main/kotlin/entity/room/RoomData.kt @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023. Smart Operating Block + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE file or at + * https://opensource.org/licenses/MIT. + */ + +package entity.room + +/** Module with all data necessary for Operating Block [Room]. */ +object RoomData { + + /** The [id] of a [Room]. */ + data class RoomId(val id: String) { + init { + require(this.id.isNotEmpty()) { + "Room ID can not be empty!" + } + } + } + + /** The possible type of [Room]. */ + enum class RoomType { + PRE_POST_OPERATING_ROOM, OPERATING_ROOM + } +}