Android注释是否可以继承?
假设我们有以下接口 -
@Retention(RetentionPolicy.SOURCE)
@StringDef({EventA.EVENT})
public @interface EventA{
String EVENT= "eventA";
}
@Retention(RetentionPolicy.SOURCE)
@StringDef({EventB.EVENT})
public @interface EventB{
String EVENT= "eventB";
}
我想声明一个函数,其中他的论点类型是这样的接口之一 -
public void foo(Event x) { // Event should be only EventA or EventB
...
}
我有没有办法实现这一目标?
Let's say we have the following interfaces -
@Retention(RetentionPolicy.SOURCE)
@StringDef({EventA.EVENT})
public @interface EventA{
String EVENT= "eventA";
}
@Retention(RetentionPolicy.SOURCE)
@StringDef({EventB.EVENT})
public @interface EventB{
String EVENT= "eventB";
}
I want to declare a function in which his argument type is one of thus interfaces such as -
public void foo(Event x) { // Event should be only EventA or EventB
...
}
Is there a way I can achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论