This repository has been archived by the owner on Oct 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(desktop): create interface MutableSchoolSupply
- Loading branch information
1 parent
fdff915
commit 3cfbcb9
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...ain/src/main/kotlin/com/intelligentbackpack/desktopdomain/entities/MutableSchoolSupply.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.intelligentbackpack.desktopdomain.entities | ||
|
||
/** | ||
* Interface for a mutable school supply. | ||
*/ | ||
interface MutableSchoolSupply<T : SchoolSupply> : SchoolSupply { | ||
|
||
/** | ||
* The school supply that replaces this one. | ||
*/ | ||
val replacedBy: Set<T> | ||
|
||
/** | ||
* The school supply that this one replaces. | ||
*/ | ||
val replace: Set<T> | ||
|
||
/** | ||
* Adds the given school supply to the school supplies that replace this one. | ||
* @param schoolSupply The school supply to add. | ||
* @return The school supply with the given school supply added. | ||
*/ | ||
fun addReplacedBy(schoolSupply: T): MutableSchoolSupply<T> | ||
|
||
/** | ||
* Adds the given school supplies to the school supplies that replace this one. | ||
* @param schoolSupplies The school supplies to add. | ||
* @return The school supply with the given school supplies added. | ||
*/ | ||
fun addReplacesBy(schoolSupplies: Set<T>): MutableSchoolSupply<T> = | ||
schoolSupplies.fold(this) { acc, schoolSupply -> acc.addReplacedBy(schoolSupply) } | ||
|
||
/** | ||
* Adds the given school supply to the school supplies that this one replaces. | ||
* @param schoolSupply The school supply to add. | ||
* @return The school supply with the given school supply added. | ||
*/ | ||
fun addReplace(schoolSupply: T): MutableSchoolSupply<T> | ||
|
||
/** | ||
* Adds the given school supplies to the school supplies that this one replaces. | ||
* @param schoolSupplies The school supplies to add. | ||
* @return The school supply with the given school supplies added. | ||
*/ | ||
fun addReplaces(schoolSupplies: Set<T>): MutableSchoolSupply<T> = | ||
schoolSupplies.fold(this) { acc, schoolSupply -> acc.addReplace(schoolSupply) } | ||
|
||
/** | ||
* Adds the given subjects to the school supply. | ||
* @param subjects The subjects to add. | ||
* @return The school supply with the given subjects added. | ||
*/ | ||
override fun addSubjects(subjects: Set<Subject>): MutableSchoolSupply<T> | ||
} |