aino-komal / mvp4g

Automatically exported from code.google.com/p/mvp4g
0 stars 0 forks source link

Improve annotation inheritance #68

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If you have the following scenario:

interface EventBus1 { 

     @Event(handlers={Presenter1.class, Presenter2.class}) 
     void event1(); 

} 

interface EventBus11 extends EventBus1 { 

     //here you have no other choice than rewriting all 
     //your handlers 
     @Event(handlers={Presenter1.class, Presenter2.class, Presenter3.class}) 
     void event1(); 

} 

If you want to override event1 to add new presenter, you have to reset all 
handlers defined by Event1. 

You can have the same scenario for other annotations like @Events.

It would be helpful to define a way to inherit annotations, maybe by adding a 
flag or a new annotation.

Original issue reported on code.google.com by plcoir...@gmail.com on 25 Jan 2011 at 2:45

GoogleCodeExporter commented 9 years ago

Original comment by plcoir...@gmail.com on 15 Mar 2011 at 1:09

GoogleCodeExporter commented 9 years ago

Original comment by plcoir...@gmail.com on 15 Mar 2011 at 1:09

GoogleCodeExporter commented 9 years ago
OOP inheritance:

package hello.there.client.event;
interface FarmEventBus { 
  @Event(
    handlers={ChickenPresenter.class, DuckPresenter.class}, /* =package-private*/
    privateHandlers={ZebraPresenter.class, AnimalHandler.class},
    protectedHandlers={MooCowPresenter.class, FarmHandler.class},
    publicHandlers={TreePresenter.class, BranchPresenter.class}
  )
  void event1(); 
} 

package hello.there.client.event;
interface CarnivalEventBus extends FarmEventBus {
  @Event(handlers={ShowCowPresenter.class, WonAwardHandler.class}) 
  void event1(); 
}

Original comment by BlessedGeek on 14 Oct 2011 at 5:53

GoogleCodeExporter commented 9 years ago
Alternatively:

@Event(handlers={...})   //package-private
@Private(handlers={...})
@Protected(handlers={...})
@Public(handlers={...})
  void eventually();

@Event // no package-private handlers
@Private(handlers={...})
@Protected(handlers={...})
@Public(handlers={...})
  void gradually();

@Event(handlers={...})   //package-private only as currently is
  void abruptly();

Original comment by BlessedGeek on 14 Oct 2011 at 6:02

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Abstract EventBus
=================
- startView specifies view interface or abstract class. Abstract EventBus 
cannot be used directly but must be inherited. An extension EventBus interface 
must specify startView that implements CarnivalView.class:

@Abstract
@Events((startView = CarnivalView.class)

- startView specifies view impl (non-abstract class). Abstract EventBus can be 
used directly but when extended, extension EventBus class must specify a class 
that satisfies the condition <V extends CarnivalViewImpl.class> as startView:

@Abstract
@Events((startView = CarnivalViewImpl.class)

Original comment by BlessedGeek on 14 Oct 2011 at 6:28