Created
July 20, 2019 03:24
-
-
Save LenKIM/e84a544c2a0bc60089c3e66ff49d7278 to your computer and use it in GitHub Desktop.
함수형프로그래밍에서 템플릿메소드
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
package templates; | |
abstract class Customer { | |
def plan | |
def Customer() { | |
plan = [] | |
} | |
def abstract checkCredit() | |
def abstract checkInventory() | |
def abstract ship() | |
def process() { | |
checkCredit() | |
checkInventory() | |
ship() | |
} | |
} | |
--- | |
package templates; | |
class CustomerBlocks { | |
def plan, checkCredit, checkInventory, ship | |
def CustomerBlocks() { | |
plan = [] | |
} | |
def process() { | |
checkCredit() | |
checkInventory() | |
ship() | |
} | |
} | |
---- | |
package templates; | |
class CustomerBlocksWithProtection { | |
def plan, checkCredit, checkInventory, ship | |
def CustomerBlocksWithProtection() { | |
plan = [] | |
} | |
// BEGIN groovy_customer_blocks | |
def process() { | |
checkCredit?.call() | |
checkInventory?.call() | |
ship?.call() | |
} | |
// END groovy_customer_blocks | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment