mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 10:58:42 +00:00
21115f4568
* added bloC design pattern * added bloC design pattern * added Readme file * fixed checkstyle warnings * added tests for the ui * fixed a test in MainTest file * separating ui from main file and adding more tests * added pom.xml plugins and properties and fixed readme.md * fixed renaming problem and added context to main * chsnged state class to record * syncing changes for conflicts * Revert "fixed conflicts" * restored files * renamed readme file and abstracted pom file
42 lines
955 B
Plaintext
42 lines
955 B
Plaintext
@startuml
|
|
package com.iluwatar.bloc {
|
|
|
|
class State {
|
|
- value : int
|
|
+ State(value : int)
|
|
+ getValue() : int
|
|
}
|
|
|
|
interface StateListener<T> {
|
|
+ onStateChange(state : T)
|
|
}
|
|
|
|
interface ListenerManager<T> {
|
|
+ addListener(listener : StateListener<T>)
|
|
+ removeListener(listener : StateListener<T>)
|
|
+ getListeners() : List<StateListener<T>>
|
|
}
|
|
|
|
class BloC {
|
|
- currentState : State
|
|
- listeners : List<StateListener<State>>
|
|
+ BloC()
|
|
+ addListener(listener : StateListener<State>)
|
|
+ removeListener(listener : StateListener<State>)
|
|
+ getListeners() : List<StateListener<State>>
|
|
- emitState(newState : State)
|
|
+ increment()
|
|
+ decrement()
|
|
}
|
|
|
|
class Main {
|
|
+ main(args : String[])
|
|
}
|
|
|
|
ListenerManager <|.. BloC
|
|
StateListener <|.. BloC
|
|
BloC o-- State
|
|
BloC *-- StateListener
|
|
}
|
|
@enduml
|