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.Object
Base Event object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Event.Type<H>
Type class used to register events with anEventBus
.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Event()
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
dispatch(H handler)
Implemented by subclasses to to invoke their handlers in a type safe manner.abstract Event.Type<H>
getAssociatedType()
Returns theEvent.Type
used to register this event, allowing anEventBus
to find handlers of the appropriate class.java.lang.Object
getSource()
Returns the source for this event.protected void
setSource(java.lang.Object source)
Set the source that triggered this event.java.lang.String
toDebugString()
This is a method used primarily for debugging.java.lang.String
toString()
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.Type
used to register this event, allowing anEventBus
to 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:
toString
in 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 theEventBus
during dispatch.- Parameters:
source
- the source of this event.- See Also:
EventBus.fireEventFromSource(Event, Object)
,EventBus.setSourceOfEvent(Event, Object)
-
-