当前位置:网站首页>Scala responsibility chain pattern
Scala responsibility chain pattern
2022-06-25 01:03:00 【Jue Niu thunder plough hot blade】
// Scala in , The case where a class inherits more than one trait is called superposition trait
object Responsibility chain pattern {
trait Handler {
def handle(data: String): Unit = {
println(" Process specific data ... 4")
println(data + " 5")
}
}
trait DataValidHandler extends Handler {
override def handle(data: String): Unit = {
println(" Check the data 3")
super.handle(data)
}
}
trait SignatureValidHandler extends Handler {
override def handle(data: String): Unit = {
println(" Inspection signature 2")
super.handle(data)
}
}
class Payment extends DataValidHandler with SignatureValidHandler {
def pay(data: String): Unit = {
println(" User initiated payment request 1")
super.handle(data)
}
}
def main(args: Array[String]): Unit = {
val p = new Payment
p.pay(" Zhang San transfers it to Sister Feng 1000 element ")
}
}
边栏推荐
- QT (35) - operate excel qxlsx qaxobject
- 热力图展示相关矩阵
- Text editor of QT project practice ---------- episode 8
- Working principle analysis of kubernetes architecture core components
- Encryption and encoding resolution
- 【Redis实现秒杀业务②】超卖问题的解决方案
- Simulation questions and answers of the latest national fire facility operator (senior fire facility operator) in 2022
- 【微服务|Sentinel】Sentinel快速入门|构建镜像|启动控制台
- Go crawler framework -colly actual combat (III) -- panoramic cartoon picture capture and download
- More pictures | explain the Nacos parameters in detail!
猜你喜欢

Easy to wear - drop down radio

Databinding quick start (still using findviewbyid?)

2022 crane driver (limited to bridge crane) examination question bank simulated examination platform operation

Applet opening traffic master

Mobile security tool jar

Custom animation (simulated win10 loading animation) - Optimization

The basic principle and application of iterator and enhanced for

Apk slimming compression experience

Simulation questions and answers of the latest national fire facility operator (senior fire facility operator) in 2022

Use and click of multitypeadapter in recycleview
随机推荐
Mobile security tool -dex2jar
Basic summary of MySQL database knowledge
Practical operation notes - notebook plus memory and ash cleaning
智能合约安全审计入门篇 —— delegatecall (2)
2022r1 quick opening pressure vessel operation test questions and answers
108页(4万字)未来公寓智能化设计平台项目方案建议书2022版
Uniapp encapsulated incentive advertisement, screen insert advertisement and banner advertisement
移动安全工具-apktool
Previous basic review
Eliminate duplicate dependencies
Decoupling pages and components using lifecycle
Custom animation (simulated win10 loading animation) - Optimization
Usage of assert
Realization of MNIST handwritten numeral recognition
JMeter socket connection sends data
Activity startup process
Hot fix sophix multi-channel patch solution
Introduction to smart contract security audit delegatecall (2)
Golang示例续期锁:Redis+Channel+sync.Mutex
2021-11-05