Class Event<H>
- java.lang.Object
-
- com.google.web.bindery.event.shared.Event<H>
-
- Type Parameters:
H- interface implemented by handlers of this kind of event
- Direct Known Subclasses:
EntityProxyChange,GwtEvent
public abstract class Event<H> extends java.lang.ObjectBase Event object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEvent.Type<H>Type class used to register events with anEventBus.
-
Constructor Summary
Constructors Modifier Constructor Description protectedEvent()Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voiddispatch(H handler)Implemented by subclasses to to invoke their handlers in a type safe manner.abstract Event.Type<H>getAssociatedType()Returns theEvent.Typeused to register this event, allowing anEventBusto find handlers of the appropriate class.java.lang.ObjectgetSource()Returns the source for this event.protected voidsetSource(java.lang.Object source)Set the source that triggered this event.java.lang.StringtoDebugString()This is a method used primarily for debugging.java.lang.StringtoString()The toString() for abstract event is overridden to avoid accidently including class literals in the compiled output.
-
-
-
Method Detail
-
getAssociatedType
public abstract Event.Type<H> getAssociatedType()
Returns theEvent.Typeused to register this event, allowing anEventBusto find handlers of the appropriate class.- Returns:
- the type
-
getSource
public java.lang.Object getSource()
Returns the source for this event. The type and meaning of the source is arbitrary, and is most useful as a secondary key for handler registration. (SeeEventBus.addHandlerToSource(com.google.web.bindery.event.shared.Event.Type<H>, java.lang.Object, H), which allows a handler to register for events of a particular type, tied to a particular source.)Note that the source is actually set at dispatch time, e.g. via
EventBus.fireEventFromSource(Event, Object).- Returns:
- object representing the source of this event
-
toDebugString
public java.lang.String toDebugString()
This is a method used primarily for debugging. It gives a string representation of the event details. This does not override the toString method because the compiler cannot always optimize toString out correctly. Event types should override as desired.- Returns:
- a string representing the event's specifics.
-
toString
public java.lang.String toString()
The toString() for abstract event is overridden to avoid accidently including class literals in the compiled output. UseEvent#toDebugString to get more information about the event.- Overrides:
toStringin classjava.lang.Object
-
dispatch
protected abstract void dispatch(H handler)
Implemented by subclasses to to invoke their handlers in a type safe manner. Intended to be called byEventBus.fireEvent(Event)orEventBus.fireEventFromSource(Event, Object).- Parameters:
handler- handler- See Also:
EventBus.dispatchEvent(Event, Object)
-
setSource
protected void setSource(java.lang.Object source)
Set the source that triggered this event. Intended to be called by theEventBusduring dispatch.- Parameters:
source- the source of this event.- See Also:
EventBus.fireEventFromSource(Event, Object),EventBus.setSourceOfEvent(Event, Object)
-
-