Given the following base classes:
package com.cartrawler.shopdirect.domain
import com.github.benmanes.caffeine.cache.Cache
import java.io.Serializable
interface Event<out T : Serializable> : Serializable {
val userId: String
val data: T
}
private data class EventTemplate<out T : Serializable>(override val userId: String, override val data: T) : Event<T>, Serializable
interface EventListener<in T : Event<Serializable>> {
fun onEvent(event: T)
}
class PreferenceChangeEvent(userId: String, preference: Preference)
: Event<Preference> by EventTemplate(userId, preference)
class ExecuteRequestStartedEvent(userId: String, msg: String)
: Event<String> by EventTemplate(userId, msg)
data class ExecuteRequestPayload(val userId: String, val serverUrl: String, val request: Request) : Serializable
class ExecuteRequestError(userId: String, throwable: Throwable)
: Event<Throwable> by EventTemplate(userId, throwable)
data class ExecuteRequestFinishedPayload(val executeRequestPayload: ExecuteRequestPayload,
val parseResult: ParseResult) : Serializable
class ExecuteRequestFinishedEvent(userId: String, payload: ExecuteRequestFinishedPayload)
: Event<ExecuteRequestFinishedPayload> by EventTemplate(userId, payload)
typealias RequestExecuteCache = Cache<ExecuteRequestPayload, ExecuteRequestFinishedEvent>
interface ExecuteRequestStartedEventListener : EventListener<ExecuteRequestStartedEvent> {
override fun onEvent(event: ExecuteRequestStartedEvent)
}
interface ExecuteRequestErrorListener : EventListener<ExecuteRequestError> {
override fun onEvent(event: ExecuteRequestError)
}
interface PreferenceChangeEventListener : EventListener<PreferenceChangeEvent> {
override fun onEvent(event: PreferenceChangeEvent)
}
Declaring the following does not work:
@UIScope
@SpringComponent
class AppUpdaterEventListener(val user: User) : ExecuteRequestErrorListener, ExecuteRequestStartedEventListener {
The compiler error is: