```class XmlSessionDBCollection( private val c...
# announcements
j
Copy code
class XmlSessionDBCollection(
    private val ctx: RoutingContext,
    private val dbCollection: TemporalNodeCollection<AbstractTemporalNode<XmlDBNode>>, AutoCloseable,
    private val user: User
) : TemporalNodeCollection<AbstractTemporalNode<XmlDBNode>>, AutoCloseable by dbCollection {
s
this one might look a little funny—you’ll need a generic and you’ll need to use a
where
clause: https://kotlinlang.org/docs/reference/generics.html#upper-bounds
👆 1
without generics, you would need an intersection type, and Kotlin doesn’t support representing those
e
the compiler actually understands that internally, but there's no way to represent it
1
union types would be pretty nice for multi-catch, https://youtrack.jetbrains.com/issue/KT-7128 - but that's another difficult design
j
how do I add the implements clause in Kotlin?
Copy code
class XmlSessionDBCollection<T> (
    private val ctx: RoutingContext,
    private val dbCollection: T,
    private val user: User
) where T : TemporalNodeCollection<AbstractTemporalNode<XmlDBNode>>, T: AutoCloseable
so, the class should implement TemporalNodeCollection<AbstractTemporalNode<XmlDBNode>> and AutoCloseable, too and most methods should be delegated to dbCollection
Can anyone help me? Thanks 🙂
e
Copy code
class XmlSessionDBCollection<T>(
    private val dbCollection: T
) : TemporalNodeCollection by dbCollection, AutoCloseable by dbCollection
    where T : TemporalNodeCollection, T : AutoCloseable
j
thanks 🙂