Skip to content

Commit a508ec9

Browse files
chore: add zone concepts
1 parent 57aa1f7 commit a508ec9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/main/kotlin/entity/zone/Zone.kt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 entity.zone
10+
11+
/**
12+
* It describes a zone inside the Operating block.
13+
* Each zone is identified by an [id] and described
14+
* by a [name] and a [description].
15+
*/
16+
data class Zone(
17+
val id: ZoneID,
18+
val name: String,
19+
val description: String,
20+
) {
21+
init {
22+
require(this.name.isNotEmpty())
23+
require(this.description.isNotEmpty())
24+
}
25+
26+
override fun equals(other: Any?): Boolean = when {
27+
other === this -> true
28+
other is Zone -> this.id == other.id
29+
else -> false
30+
}
31+
32+
override fun hashCode(): Int = this.id.hashCode()
33+
}
34+
35+
/**
36+
* It represents the Operating Block zone ID [value].
37+
*/
38+
data class ZoneID(val value: String) {
39+
init {
40+
// Constructor validation: the id must not be empty
41+
require(this.value.isNotEmpty())
42+
}
43+
}

0 commit comments

Comments
 (0)