From 3cfbcb965a8902e25a10188bef8dcb9f91406c9a Mon Sep 17 00:00:00 2001 From: Andrea Brighi Date: Wed, 10 May 2023 20:47:02 +0200 Subject: [PATCH] feat(desktop): create interface MutableSchoolSupply --- .../entities/MutableSchoolSupply.kt | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 desktopDomain/src/main/kotlin/com/intelligentbackpack/desktopdomain/entities/MutableSchoolSupply.kt diff --git a/desktopDomain/src/main/kotlin/com/intelligentbackpack/desktopdomain/entities/MutableSchoolSupply.kt b/desktopDomain/src/main/kotlin/com/intelligentbackpack/desktopdomain/entities/MutableSchoolSupply.kt new file mode 100644 index 00000000..a130a12b --- /dev/null +++ b/desktopDomain/src/main/kotlin/com/intelligentbackpack/desktopdomain/entities/MutableSchoolSupply.kt @@ -0,0 +1,54 @@ +package com.intelligentbackpack.desktopdomain.entities + +/** + * Interface for a mutable school supply. + */ +interface MutableSchoolSupply : SchoolSupply { + + /** + * The school supply that replaces this one. + */ + val replacedBy: Set + + /** + * The school supply that this one replaces. + */ + val replace: Set + + /** + * 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 + + /** + * 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): MutableSchoolSupply = + 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 + + /** + * 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): MutableSchoolSupply = + 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): MutableSchoolSupply +}