@Target(value=TYPE) @Retention(value=SOURCE) @Inherited public @interface GenEvent
@GenEvent
public class FooChanged {
Foo foo;
boolean originator;
}
gwt-platform will generate two classes, FooChangedEvent and FooChangedHandler.
FooChangedEvent will have fields, getters, and a constructor for foo and
originator, plus static getType(), instance dispatch, etc., for it to
function correctly as a GwtEvent.
FooChangedHandler will be an interface with a onFooChanged method that takes
a FooChangedEvent parameter.
Notes:
There is no naming requirement for your class name. It will be appended with
Event and Handler.
Using @Order:
The order the the fields can be optionally specified using the @Order
annotation. If @Order is not used, then the order of the parameters to the
constructor and to fire() is undefined.
If you type:
@GenEvent
public class FooChanged {
@Order(1) Foo foo;
@Order(2) int bar;
@Order(3) boolean originator;
}
The following constructor and fire methods will be generated:
...
FooChangedEvent(Foo foo, int bar, boolean originator)
...
public static void fire(HasEventBus source, Foo foo, int bar, boolean originator)
...
Omitting the @Order annotations would yield:
...
FooChangedEvent(int bar, Foo foo, boolean originator)
...
public static void fire(HasEventBus source, int bar, Foo foo, boolean originator)
...
Using @Optional:
If @Optional is used together with @GenEvent, an additional fire method is generated.
If you type:
@GenEvent
public class FooChanged {
@Optional @Order(1) Foo foo;
@Order(2) int bar;
@Optional @Order(3) boolean originator;
}
The following constructors and fire methods will be generated:
...
FooChangedEvent(int bar)
FooChangedEvent(Foo foo, int bar, boolean originator)
...
public static void fire(HasEventBus source, int bar)
public static void fire(HasEventBus source, Foo foo, int bar, boolean originator)
...
Copyright © 2010-2014 ArcBees. All Rights Reserved.