From e310e787a4c3d05541fceb9d22aa7f304e3c1b6c Mon Sep 17 00:00:00 2001 From: iProdigy <8106344+iProdigy@users.noreply.github.com> Date: Wed, 28 Jun 2023 14:38:09 -0500 Subject: [PATCH] chore: add Event constructor to avoid random uuid call (#170) --- .../philippheuer/events4j/core/domain/Event.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/github/philippheuer/events4j/core/domain/Event.java b/core/src/main/java/com/github/philippheuer/events4j/core/domain/Event.java index 5561bfa..c524194 100644 --- a/core/src/main/java/com/github/philippheuer/events4j/core/domain/Event.java +++ b/core/src/main/java/com/github/philippheuer/events4j/core/domain/Event.java @@ -40,8 +40,18 @@ public abstract class Event implements IEvent { * Constructor */ public Event() { - eventId = UUID.randomUUID().toString(); - firedAtInstant = Instant.now(); + this(UUID.randomUUID().toString(), Instant.now()); + } + + /** + * Constructor + * + * @param eventId Unique event id + * @param firedAt Timestamp of the event firing + */ + public Event(String eventId, Instant firedAt) { + this.eventId = eventId; + this.firedAtInstant = firedAt; } @Override