From c190111de17968b8f69a6ae7dcc5ab56f925cd6c Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Sun, 2 May 2021 04:14:00 +0200 Subject: [PATCH] feat: completed EventBuilder with complete exception-based event checking for all events --- .../gamelibrary/events/EventBuilder.java | 98 +++++++++++++++++-- 1 file changed, 88 insertions(+), 10 deletions(-) diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilder.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilder.java index 89a6ad9..a893b94 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilder.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/events/EventBuilder.java @@ -5,6 +5,7 @@ import uulm.teamname.marvelous.gamelibrary.entities.Entity; import uulm.teamname.marvelous.gamelibrary.entities.EntityID; import uulm.teamname.marvelous.gamelibrary.entities.StoneType; +import java.util.Arrays; import java.util.HashMap; /** @@ -46,12 +47,12 @@ public class EventBuilder { private String teamIdentifier; private HashMap customContent; - /** - * Creates a new {@link EventBuilder} used for building {@link Event}s - */ - public EventBuilder() { - - } +// /** +// * Creates a new {@link EventBuilder} used for building {@link Event}s +// */ +// public EventBuilder() { +// +// } /** @@ -318,11 +319,14 @@ public class EventBuilder { * @throws IllegalStateException meaning that the event is non-valid for the current builder state */ private void throwException() throws IllegalStateException { - throw new IllegalStateException("Properties malformed for " + this.type); + throw new IllegalStateException("Properties malformed for " + this.type + ".\n" + + "Builder properties: " + this.notNullToString()); } /** - * Builds a generic {@link GameEvent} from the values given to the builder + * Builds a generic {@link GameEvent} from the values given to the builder. + * This method checks for the correctness of the event before building it. If this is not desired, + * use the {@link #buildGameEventUnchecked()} method instead *