简体   繁体   English

用泛型类型扩展抽象类?

[英]Extend Abstract Class with Generic Types?

How can I extent an abstract class like the following which has generic arguments? 我如何扩展具有通用参数的如下所示的抽象类?

@Singleton
public abstract class Presenter<V extends View, Proxy_ extends Proxy<?>> extends PresenterWidget<V> {

...
}

Class Presenter has simplified generic type Presenter<V, Proxy_> where Presenter类具有简化的通用类型Presenter<V, Proxy_> ,其中

  • V extends View V延伸View
  • Proxy_ extends Proxy<?> Proxy_扩展Proxy<?>

Extending class should look like this: 扩展类应如下所示:

public class MyPresenter extends Presenter<MyView, MyProxy> {
    ...
}

where 哪里

  • MyView extends View MyView扩展View
  • MyProxy extends Proxy<?> MyProxy扩展了Proxy<?>

To extend MariuszS's answer: Generally the presenter defines the view interface: 扩展MariuszS的答案:通常,演示者定义视图接口:

public class MyPresenter extends Presenter<MyPresenter.MyView, MyProxy> {
    public static interface MyView extends View {
    ...
    }
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM