Skip to content

Instantly share code, notes, and snippets.

@le0nidas
Created September 27, 2020 14:53
Show Gist options
  • Save le0nidas/68313941ca058f7799c0d83969402538 to your computer and use it in GitHub Desktop.
Save le0nidas/68313941ca058f7799c0d83969402538 to your computer and use it in GitHub Desktop.
abstract class BaseAction(
private val nextAction: Action?
) : Action {
override fun execute(response: Response) {
nextAction?.execute(response)
}
}
class Print : Action {
override val name: String = "print"
override fun execute(response: Response) {
println("printing ${response.value}...")
}
}
class PrintInErrorStream(
nextAction: Action?
) : BaseAction(nextAction) {
override val name: String = "print"
override fun execute(response: Response) {
if (response.isError) {
System.err.println("printing (in error stream) ${response.value}...")
return
}
super.execute(response)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment