Skip to content

Commit

Permalink
chore: add serializable in order to use kotlinx.serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaGiulianelli committed Mar 7, 2023
1 parent ef8ac72 commit 0537dae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/kotlin/entity/environment/EnvironmentData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@

package entity.environment

import kotlinx.serialization.Serializable

/**
* Temperature concept.
* It is described by the current temperature [value] expressed in a [unit].
*/
@Serializable
data class Temperature(val value: Double, val unit: TemperatureUnit = TemperatureUnit.CELSIUS)

/**
* This enum describe the possible [Temperature] unit of measurement.
*/
@Serializable
enum class TemperatureUnit {
/**
* Celsius unit.
Expand All @@ -28,12 +32,14 @@ enum class TemperatureUnit {
* Humidity concept.
* It is described by the current [percentage] of humidity. So it describes the Relative Humidity.
*/
@Serializable
data class Humidity(val percentage: Double)

/**
* Luminosity concept.
* It is described by the current luminosity [value] expressed in a [unit].
*/
@Serializable
data class Luminosity(val value: Double, val unit: LightUnit = LightUnit.LUX) {
init {
// Constructor validation
Expand All @@ -44,6 +50,7 @@ data class Luminosity(val value: Double, val unit: LightUnit = LightUnit.LUX) {
/**
* This enum describe the possible [Luminosity] unit of measurement.
*/
@Serializable
enum class LightUnit {
/**
* Lux unit.
Expand All @@ -55,4 +62,5 @@ enum class LightUnit {
* Describe the presence inside a Room of the Operating Block.
* @param[presenceDetected] true if someone is in the room, false otherwise.
*/
@Serializable
data class Presence(val presenceDetected: Boolean)
5 changes: 5 additions & 0 deletions src/main/kotlin/entity/zone/Room.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import entity.environment.Humidity
import entity.environment.Luminosity
import entity.environment.Presence
import entity.environment.Temperature
import kotlinx.serialization.Serializable

/**
* It describes a room inside the Operating Block.
Expand All @@ -20,6 +21,7 @@ import entity.environment.Temperature
* The Building Management system has the objective to collect [environmentalData]
* of the rooms withing the Operating Block.
*/
@Serializable
data class Room(
val id: RoomID,
val type: RoomType,
Expand All @@ -40,6 +42,7 @@ data class Room(
* Identification of a [Room].
* @param[value] the id.
*/
@Serializable
data class RoomID(val value: String) {
init {
// Constructor validation: The id must not be empty
Expand All @@ -56,6 +59,7 @@ data class RoomID(val value: String) {
* - the [presence] of someone in the room
* All the data may be not present.
*/
@Serializable
data class RoomEnvironmentalData(
val temperature: Temperature? = null,
val humidity: Humidity? = null,
Expand All @@ -66,6 +70,7 @@ data class RoomEnvironmentalData(
/**
* Describes the type of [Room].
*/
@Serializable
enum class RoomType {
/** It is the Pre/Post Operating Room. */
PRE_OPERATING_ROOM,
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/entity/zone/Zone.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

package entity.zone

import kotlinx.serialization.Serializable

/**
* It describes a zone inside the Operating block.
* Each zone is identified by an [id] and described
Expand Down Expand Up @@ -35,6 +37,7 @@ data class Zone(
/**
* It represents the Operating Block zone ID [value].
*/
@Serializable
data class ZoneID(val value: String) {
init {
// Constructor validation: the id must not be empty
Expand Down

0 comments on commit 0537dae

Please sign in to comment.