Package org.libvirt.event
Class DomainEvent
- java.lang.Object
-
- org.libvirt.event.DomainEvent
-
public final class DomainEvent extends java.lang.Object
Contains information about a life cycle change of a domain.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 }
- Since:
- 1.5.2
- See Also:
LifecycleListener
-
-
Constructor Summary
Constructors Constructor Description DomainEvent(DomainEventType type, int code)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends java.lang.Enum<T> & DomainEventDetail>
TgetDetail()
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()
-
-
-
Constructor Detail
-
DomainEvent
public DomainEvent(DomainEventType type, int code)
-
-
Method Detail
-
getType
public DomainEventType getType()
Returns the type of event which occurred.
-
getDetail
public <T extends java.lang.Enum<T> & DomainEventDetail> T getDetail()
Returns the corresponding domain event detail in regard to the DomainEventType of this instance.- Returns:
- a constant of one of the enums implementing the
DomainEventDetail
interface
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-