Class AbstractGenericEvent<G,T>
- Type Parameters:
G
- The generic type of the event onto which to distinguishT
- The entity type forAbstractEntityChangedEvent
.
- All Implemented Interfaces:
DESEvent
,SlingshotEvent
,ReifiedEvent<G>
- Direct Known Subclasses:
ModelVisited
SampleEvent<TypeA>
and SampleEvent<TypeB>
are published, then
the event dispatcher must be able to distinguish them, since otherwise the
generic types are erased at runtime and the dispatcher would call all event
handlers listening to SampleEvent
regardless of their specific type.
To distinguish the events, a TypeToken
is used which can be accessed
by the event dispatcher.
An example event could be:
public final class SomeGenericEvent<T> extends AbstractGenericEvent<T, EntityType>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractGenericEvent
(Class<G> concreteClass, T entity, double delay) Constructs an AbstractGenericEvent with a concrete Class information.protected
AbstractGenericEvent
(T entity, double delay) Constructs a AbstractGenericEvent without a concrete Class instance. -
Method Summary
Methods inherited from class org.palladiosimulator.analyzer.slingshot.common.events.AbstractEntityChangedEvent
getEntity, getId
Methods inherited from class org.palladiosimulator.analyzer.slingshot.common.events.AbstractSimulationEvent
delay, getName, setTime, time
-
Constructor Details
-
AbstractGenericEvent
Constructs a AbstractGenericEvent without a concrete Class instance. Here, aTypeToken
is generated.Note that if the type is not known at compile-time, the TypeToken will contain the type of the known super-class. For example, if a class
A
has three sub-classesB, C, D
, but the concrete class is not known and this constructor is used (i.e.new GenericEvent<A, A>(b, 0);
), thengetTypeToken()
will returnA
, even thoughb
is of instanceB
. In this case, use#AbstractGenericEvent(Class, T, double)
instead.- Parameters:
entity
- The entity forAbstractEntityChangedEvent
.delay
- The delay of the event.
-
AbstractGenericEvent
Constructs an AbstractGenericEvent with a concrete Class information. TheTypeToken
is generated by usingconcreteClass
, hencegetTypeToken()
will return the type fromconcreteClass
.This constructor is useful if the concrete class information is not known at compile time. Otherwise, if it is possible to instantiate as follows:
new GenericEvent<A, Entity>(entity, 0);
, then useAbstractGenericEvent(T, double)
instead.- Parameters:
concreteClass
- The concrete class of the typeG
.entity
- The entity forAbstractEntityChangedEvent
.delay
- the delay of the event.
-
-
Method Details
-
getTypeToken
- Specified by:
getTypeToken
in interfaceReifiedEvent<G>
-
getGenericType
-