Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Annotations vs. Interface in Guava EventBus

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?

like image 998
deamon Avatar asked Jan 24 '12 11:01

deamon


1 Answers

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

like image 148
Mairbek Khadikov Avatar answered Oct 13 '22 11:10

Mairbek Khadikov