Class 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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T extends java.lang.Enum<T> & DomainEventDetail>
      T
      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()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

    • 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 class java.lang.Object