1 package com.reallifedeveloper.common.domain.event;
2
3 import java.io.Serializable;
4 import java.time.ZonedDateTime;
5
6 import com.reallifedeveloper.common.domain.DomainObject;
7
8 /**
9 * A domain-driven design domain event, i.e., something that happened that domain experts care about.
10 *
11 * @author RealLifeDeveloper
12 */
13 public interface DomainEvent extends DomainObject<DomainEvent>, Serializable {
14
15 /**
16 * Gives the time the event occurred.
17 *
18 * @return the time the event occurred
19 */
20 ZonedDateTime eventOccurredOn();
21
22 /**
23 * Gives the version of this event. This is useful when deserializing an event.
24 * <p>
25 * The version should start at 1 and be incremented each time the event class is updated in a way
26 * that affects serialization/deserialization.
27 *
28 * @return the version of this event
29 */
30 int eventVersion();
31
32 }