public final class DomainEvent
extends java.lang.Object
This includes the domain event that occurred together with further details about that event.
Usage:
int onLifecycleChange(Domain dom, DomainEvent info) {
switch (info.getType()) {
case STARTED:
StartedDetail detail = info.getDetail();
switch (detail) {
case BOOTED:
...
break;
...
}
}
}
}
Note, that a ClassCastException will be thrown at runtime when assigning to the wrong detail enumeration type:
DomainEvent info;
if (info.getType() == DomainEventType.STARTED) {
// info.getDetails() returns a StartedDetail enum
StoppedDetail detail = info.getDetail(); // throws ClassCastException
}
LifecycleListener
Constructor and Description |
---|
DomainEvent(DomainEventType type,
int code) |
Modifier and Type | Method and Description |
---|---|
<T extends java.lang.Enum<T> & DomainEventDetail> |
getDetail()
Returns the corresponding domain event detail in regard to
the DomainEventType of this instance.
|
DomainEventType |
getType()
Returns the type of event which occurred.
|
java.lang.String |
toString() |
public DomainEvent(DomainEventType type, int code)
public DomainEventType getType()
public <T extends java.lang.Enum<T> & DomainEventDetail> T getDetail()
DomainEventDetail
interfacepublic java.lang.String toString()
toString
in class java.lang.Object