Ok, let me give you additional context: Assume I h...
# arrow
p
Ok, let me give you additional context: Assume I have a class with some business logic. Lets call it
BL
that uses a source of data. The source of data is expressed by
Copy code
interface Source<V> {
  fun random(): V
}
The BL started as a class, for example like:
Copy code
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:
Copy code
interface JavaAsyncSource<V> {
  fun random(): CompletionStage<V>
}
And finally a third interface is born to support asynchronous sources in "native" kotlin:
Copy code
interface AsyncSource<V> {
  suspend fun random(): V
}
So what's left to do? Implement 2 new
BL
that take
JavaAsyncSource
and
AsyncSource
. So:
Copy code
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"