我(来自akka)上了一堂课,看起来像这样:
public class HighLevelEventBus extends ScanningEventBus<Class<? extends TimedEvent>, Integer, String> {...}
我想做的就是将其从Class<? extends TimedEvent>
变成某种对象,例如<T extends TimedEvent>
。我之所以想这样做,是因为在ScanningEventBus中有一些方法,如
@Override
public boolean matches(String classifier, Class<? extends TimedEvent> event) {
return nuull;
}
在此方法中,我想做类似event.someMethodFromTimedEvent()
的事情,但我必须先做:TimedEvent timedEvent = event.cast(event.getClass()); timedEvent.someMethodFromTimedEvent();
,这对我来说似乎是错误的。
我的目标是拥有与此方法类似的内容:
public <T extends TimedEvent> boolean matches(String somethingSomething, T event) {
return classifier.equals(event.someMethodFromTimedEvent());
}
但是我需要覆盖原始的matches(...)
方法,因此,我需要更改ScanningEventBus<Class<? extends TimedEvent>, Integer, String> {...}