Class DomainEvent

java.lang.Object
org.libvirt.event.DomainEvent

public final class DomainEvent extends 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:
  • Constructor Details

  • Method Details

    • getType

      public DomainEventType getType()
      Returns the type of event which occurred.
    • getDetail

      public <T extends 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 String toString()
      Overrides:
      toString in class Object