mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 10:58:42 +00:00
refactor: Eliminate Optional from fields and parameters for async method invocation (#2830)
This commit is contained in:
@@ -9,7 +9,8 @@ package com.iluwatar.async.method.invocation {
|
||||
+ main(args : String[]) {static}
|
||||
}
|
||||
interface AsyncCallback<T> {
|
||||
+ onComplete(T, Optional<Exception>) {abstract}
|
||||
+ onComplete(T) {abstract}
|
||||
+ onError(Exception) {abstract}
|
||||
}
|
||||
interface AsyncExecutor {
|
||||
+ endProcess(AsyncResult<T>) : T {abstract}
|
||||
@@ -32,7 +33,7 @@ package com.iluwatar.async.method.invocation {
|
||||
~ COMPLETED : int {static}
|
||||
~ FAILED : int {static}
|
||||
~ RUNNING : int {static}
|
||||
~ callback : Optional<AsyncCallback<T>>
|
||||
~ callback : AsyncCallback<T>
|
||||
~ exception : Exception
|
||||
~ lock : Object
|
||||
~ state : int
|
||||
@@ -40,12 +41,15 @@ package com.iluwatar.async.method.invocation {
|
||||
~ CompletableResult<T>(callback : AsyncCallback<T>)
|
||||
+ await()
|
||||
+ getValue() : T
|
||||
~ hasCallback() : boolean
|
||||
+ isCompleted() : boolean
|
||||
~ setException(exception : Exception)
|
||||
~ setValue(value : T)
|
||||
}
|
||||
}
|
||||
ThreadAsyncExecutor ..|> AsyncCallback
|
||||
ThreadAsyncExecutor ..|> AsyncResult
|
||||
ThreadAsyncExecutor ..|> AsyncExecutor
|
||||
CompletableResult ..+ ThreadAsyncExecutor
|
||||
ThreadAsyncExecutor ..|> AsyncExecutor
|
||||
CompletableResult ..|> AsyncResult
|
||||
@enduml
|
||||
CompletableResult ..|> AsyncResult
|
||||
@enduml
|
||||
|
||||
Reference in New Issue
Block a user