Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
feat(desktop): create interface MutableSchoolSupply
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaBrighi committed May 10, 2023
1 parent fdff915 commit 3cfbcb9
Showing 1 changed file with 54 additions and 0 deletions.
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>
}

0 comments on commit 3cfbcb9

Please sign in to comment.