forked from iluwatar/java-design-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpromise.urm.puml
79 lines (79 loc) · 2.5 KB
/
promise.urm.puml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
@startuml
package com.iluwatar.promise {
class App {
- DEFAULT_URL : String {static}
- LOGGER : Logger {static}
- executor : ExecutorService
- stopLatch : CountDownLatch
- App()
- calculateLineCount()
- calculateLowestFrequencyChar()
- characterFrequency() : Promise<Map<Character, Integer>>
- countLines() : Promise<Integer>
- download(urlString : String) : Promise<String>
- lowestFrequencyChar() : Promise<Character>
+ main(args : String[]) {static}
- promiseUsage()
- stop()
- taskCompleted()
}
class Promise<T> {
- exceptionHandler : Consumer<? super Throwable>
- fulfillmentAction : Runnable
+ Promise<T>()
+ fulfill(value : T)
+ fulfillExceptionally(exception : Exception)
+ fulfillInAsync(task : Callable<T>, executor : Executor) : Promise<T>
- handleException(exception : Exception)
+ onError(exceptionHandler : Consumer<? super Throwable>) : Promise<T>
- postFulfillment()
+ thenAccept(action : Consumer<? super T>) : Promise<Void>
+ thenApply(func : Function<? super T, V>) : Promise<V>
}
-class ConsumeAction {
- action : Consumer<? super T>
- dest : Promise<Void>
- src : Promise<T>
- ConsumeAction(src : Promise<T>, dest : Promise<T>, action : Consumer<T>)
+ run()
}
-class TransformAction<V> {
- dest : Promise<V>
- func : Function<? super T, V>
- src : Promise<T>
- TransformAction<V>(src : Promise<T>, dest : Promise<T>, func : Function<T, R>)
+ run()
}
~class PromiseSupport<T> {
- COMPLETED : int {static}
- FAILED : int {static}
- LOGGER : Logger {static}
- RUNNING : int {static}
- exception : Exception
- lock : Object
- state : int
- value : T
~ PromiseSupport<T>()
+ cancel(mayInterruptIfRunning : boolean) : boolean
~ fulfill(value : T)
~ fulfillExceptionally(exception : Exception)
+ get() : T
+ get(timeout : long, unit : TimeUnit) : T
+ isCancelled() : boolean
+ isDone() : boolean
}
class Utility {
- LOGGER : Logger {static}
+ Utility()
+ characterFrequency(fileLocation : String) : Map<Character, Integer> {static}
+ countLines(fileLocation : String) : Integer {static}
+ downloadFile(urlString : String) : String {static}
+ lowestFrequencyChar(charFrequency : Map<Character, Integer>) : Character {static}
}
}
TransformAction --+ Promise
TransformAction --> "-src" Promise
ConsumeAction --+ Promise
ConsumeAction --> "-src" Promise
Promise --|> PromiseSupport
@enduml