Skip to content

Instantly share code, notes, and snippets.

@le0nidas
Created February 14, 2021 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save le0nidas/24048dea0578f0f536a4fe88e0ca5cea to your computer and use it in GitHub Desktop.
Save le0nidas/24048dea0578f0f536a4fe88e0ca5cea to your computer and use it in GitHub Desktop.
// somewhere in the code
if (task.status == Status.NotStarted && task.createdAt < LocalDate.of(2021, 1, 14) && task.subscribers.isEmpty()) {
task.close()
}
// which might have led to this API
class Task(
initialStatus: Status,
val createdAt: LocalDate
) {
var status: Status = initialStatus
private set
private val innerSubscribers = mutableListOf<Subscriber>()
val subscribers: List<Subscriber> = innerSubscribers
fun add(subscriber: Subscriber) {
innerSubscribers.add(subscriber)
}
fun close() {
status = Status.Resolved
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment