We can leverage the lambda expressins of Java 8 onwards to implement command design pattern instead of traditional non functional way
59 lines
1.3 KiB
Plaintext
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
|