Skip to content

Commit e310e78

Browse files
authored
chore: add Event constructor to avoid random uuid call (#170)
1 parent 4bd52b5 commit e310e78

File tree

1 file changed

+12
-2
lines changed
  • core/src/main/java/com/github/philippheuer/events4j/core/domain

1 file changed

+12
-2
lines changed

core/src/main/java/com/github/philippheuer/events4j/core/domain/Event.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,18 @@ public abstract class Event implements IEvent {
4040
* Constructor
4141
*/
4242
public Event() {
43-
eventId = UUID.randomUUID().toString();
44-
firedAtInstant = Instant.now();
43+
this(UUID.randomUUID().toString(), Instant.now());
44+
}
45+
46+
/**
47+
* Constructor
48+
*
49+
* @param eventId Unique event id
50+
* @param firedAt Timestamp of the event firing
51+
*/
52+
public Event(String eventId, Instant firedAt) {
53+
this.eventId = eventId;
54+
this.firedAtInstant = firedAt;
4555
}
4656

4757
@Override

0 commit comments

Comments
 (0)