Skip to content

Instantly share code, notes, and snippets.

@mucahitkurt
Created July 16, 2020 13:31
Show Gist options
  • Save mucahitkurt/7c4dda77d71e9363afb82871fdc9bf85 to your computer and use it in GitHub Desktop.
Save mucahitkurt/7c4dda77d71e9363afb82871fdc9bf85 to your computer and use it in GitHub Desktop.
class InvalidOrderStateToCancel: RuntimeException()
class Order(val orderSpecification: OrderSpecification) {
fun cancel() {
if (!orderSpecification.isCancellable(this)) {
throw InvalidOrderStateToCancel()
}
//…cancel order
}
fun isCancelled(): Boolean {
//…check order status
return true
}
}
class OrderSpecification {
fun isCancellable(order: Order): Boolean {
//…check order status
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment