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
class TaskChecker( | |
seamToAssigner: ((Task) -> Unit)? = null | |
) { | |
private val safeSendTaskToAssigner: (Task) -> Unit = seamToAssigner ?: ::sendTaskToAssigner | |
fun check(task: Task): CheckResult { | |
if (isNotCreatedInCurrentWeek(task)) return Invalid | |
if (isResolved(task)) return Invalid | |
if (isNotAssigned(task)) return Invalid | |
return Valid | |
} | |
private fun isNotAssigned(task: Task): Boolean { | |
if (task.assignedTo != Nobody) return false | |
safeSendTaskToAssigner(task) | |
return true | |
} | |
private fun sendTaskToAssigner(task: Task) { | |
val connection = Connection() | |
val assigner = TaskAssigner(connection) | |
assigner.add(task) | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment