Annotations vs. Interface in Guava EventBus

2019-04-20 11:19发布

The Guava developers chose to use annotations:

class EventBusChangeRecorder {
  @Subscribe 
  void recordCustomerChange(ChangeEvent e) {
    recordChange(e.getChange());
  }
}

... instead of classic interfaces:

class EventBusChangeRecorder implements Handler<ChangeEvent>{
  void handle(ChangeEvent e) {
    recordChange(e.getChange());
  }
}

This makes compile time checking impossible. So I'm wondering what is the advantage of this approach.

Do you see any advantages of annotations here?

1条回答
劳资没心,怎么记你
2楼-- · 2019-04-20 12:12

I think that the question is answered on the Guava wiki.

查看更多
登录 后发表回答