Rakesh Venkatesh 4ff196ce35 Refactor the command pattern to use lambda functions
We can leverage the lambda expressins of Java 8 onwards
to implement command design pattern instead of traditional
non functional way
2020-10-13 16:45:19 +02:00

59 lines
1.3 KiB
Plaintext

@startuml
package com.iluwatar.command {
class App {
+ App()
+ main(args : String[]) {static}
}
class Goblin {
+ Goblin()
+ toString() : String
+ changeSize()
+ changeVisibility()
}
enum Size {
+ NORMAL {static}
+ SMALL {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Size {static}
+ values() : Size[] {static}
}
abstract class Target {
- LOGGER : Logger {static}
- size : Size
- visibility : Visibility
+ Target()
+ getSize() : Size
+ getVisibility() : Visibility
+ printStatus()
+ setSize(size : Size)
+ setVisibility(visibility : Visibility)
+ toString() : String {abstract}
}
enum Visibility {
+ INVISIBLE {static}
+ VISIBLE {static}
- title : String
+ toString() : String
+ valueOf(name : String) : Visibility {static}
+ values() : Visibility[] {static}
}
class Wizard {
- LOGGER : Logger {static}
- redoStack : Deque<Runnable>
- undoStack : Deque<Runnable>
+ Wizard()
+ castSpell(Runnable : runnable)
+ redoLastSpell()
+ toString() : String
+ undoLastSpell()
}
}
Target --> "-size" Size
Wizard --> "-changeSize" Goblin
Wizard --> "-changeVisibility" Goblin
Target --> "-visibility" Visibility
Goblin --|> Target
App --> "castSpell" Wizard
@enduml