Pedro Silva
09/20/2019, 11:52 AMBL that uses a source of data. The source of data is expressed by
interface Source<V> {
fun random(): V
}
The BL started as a class, for example like:
class BL(val srcU: Source<User>, val srcC: Source<Company>)
The next step is to support this source in Java asynchonously (the synchronous version expressed by Source is compatible with java) so a new interface is born:
interface JavaAsyncSource<V> {
fun random(): CompletionStage<V>
}
And finally a third interface is born to support asynchronous sources in "native" kotlin:
interface AsyncSource<V> {
suspend fun random(): V
}
So what's left to do? Implement 2 new BL that take JavaAsyncSource and AsyncSource. So:
class BL(val srcU: Source<User>, val srcC: Source<Company>)
class BL(val srcU: JavaAsyncSource<User>, val srcC: JavaAsyncSource<Company>)
class BL(val srcU: AsyncSource<User>, val srcC: AsyncSource<Company>)
Obviosuly the only thing that changes is what wraps V. The BL it self is the same for all 3 cases.
My last question was to confirm I can support all 3 cases with "Generic containers"