From a1099e2704aca7539debd968004600197c08e50b Mon Sep 17 00:00:00 2001 From: "Ahmad K. Bawaneh" Date: Sun, 30 Jun 2024 16:30:20 +0300 Subject: [PATCH] fix build --- .../org/dominokit/brix/api/HasContext.java | 27 +++++++++++++++++-- pom.xml | 8 ++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/domino-brix-client/src/main/java/org/dominokit/brix/api/HasContext.java b/domino-brix-client/src/main/java/org/dominokit/brix/api/HasContext.java index 4f766f2..d318c8c 100644 --- a/domino-brix-client/src/main/java/org/dominokit/brix/api/HasContext.java +++ b/domino-brix-client/src/main/java/org/dominokit/brix/api/HasContext.java @@ -20,10 +20,14 @@ public interface HasContext { default void update(T context) { + update(context, Operation.UPDATED); + } + + default void update(T context, Operation operation) { getContextListeners() .forEach( contextListener -> { - contextListener.onContextUpdated(context); + contextListener.onContextChange(context, operation); }); } @@ -40,6 +44,25 @@ default T removeChangeListener(ContextListener contextListener) { } interface ContextListener { - void onContextUpdated(T context); + void onContextChange(T context, Operation operation); + } + + interface Operation { + Operation CREATED = () -> "CREATED"; + Operation UPDATED = () -> "UPDATED"; + Operation DELETED = () -> "DELETED"; + + String getKey(); + + default boolean isEqualTo(Operation other) { + return getKey().equals(other.getKey()); + } + + default Operation when(Operation other, Runnable runnable) { + if (isEqualTo(other)) { + runnable.run(); + } + return this; + } } } diff --git a/pom.xml b/pom.xml index 76819ed..e740e79 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,7 @@ https://github.com/DominoKit/domino-brix + ossrh @@ -406,4 +407,11 @@ + + + + SNAPSHOTS + https://oss.sonatype.org/content/repositories/snapshots + + \ No newline at end of file