Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save IosephKnecht/5e023eda0c77a1b62e45d1d58bc75a4d to your computer and use it in GitHub Desktop.
Save IosephKnecht/5e023eda0c77a1b62e45d1d58bc75a4d to your computer and use it in GitHub Desktop.
HandBreadth Sample
interface HandBreadthActionHandler {
fun littleFingerAction()
fun foreFingerAction()
fun middleFingerAction()
fun ringFingerAction()
fun thumbAction()
}
enum class HandBreadth(val action: Function1<HandBreadthActionHandler, Unit>) {
LITTLE_FINGER(action = HandBreadthActionHandler::littleFingerAction),
FORE_FINGER(action = HandBreadthActionHandler::foreFingerAction),
MIDDLE_FINGER(action = HandBreadthActionHandler::middleFingerAction),
RING_FINGER(action = HandBreadthActionHandler::ringFingerAction),
THUMB(action = HandBreadthActionHandler::thumbAction)
}
interface ControllerContract {
fun handleHandBreadthAction(handBreadth: HandBreadth)
}
internal class Controller : ControllerContract, HandBreadthActionHandler {
override fun littleFingerAction() = Unit
override fun foreFingerAction() = Unit
override fun middleFingerAction() = Unit
override fun ringFingerAction() = Unit
override fun thumbAction() = Unit
override fun handleHandBreadthAction(handBreadth: HandBreadth) {
handBreadth.action.invoke(this)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment