From dfd665a3b84bc56daf169ffb2e455f3198db5c33 Mon Sep 17 00:00:00 2001 From: tommyskeff Date: Wed, 27 Dec 2023 00:58:50 +0000 Subject: [PATCH] release 0.1.2 --- README.md | 4 ++-- pom.xml | 2 +- .../tommyjs/jobserve/attribute/AttributeHolder.java | 10 ++++++++++ .../dev/tommyjs/jobserve/observer/ObserverList.java | 9 +++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dd1cd1f..18600a3 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ It is **worth noting** that observing an object **does not** prevent the object ### Dependency -We are currently on version `0.1.1`. +We are currently on version `0.1.2`. ```xml @@ -32,7 +32,7 @@ We are currently on version `0.1.1`. dev.tommyjs JObserve - 0.1.1 + 0.1.2 compile diff --git a/pom.xml b/pom.xml index b10baa8..661bd1b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ dev.tommyjs JObserve - 0.1.1 + 0.1.2 20 diff --git a/src/main/java/dev/tommyjs/jobserve/attribute/AttributeHolder.java b/src/main/java/dev/tommyjs/jobserve/attribute/AttributeHolder.java index aa18653..dfb45d7 100644 --- a/src/main/java/dev/tommyjs/jobserve/attribute/AttributeHolder.java +++ b/src/main/java/dev/tommyjs/jobserve/attribute/AttributeHolder.java @@ -46,10 +46,20 @@ default void setAttribute(@NotNull AttributeKey key, @Nullable T value) { return getAttributes().getAttributeOrSetDefault(key, supplier); } + default T getAttributeAndUpdate(@NotNull AttributeKey key, @NotNull Function<@Nullable T, @Nullable T> function) { + return getAttributes().getAndUpdate(key, function); + } + + @Deprecated(forRemoval = true, since = "0.2.0") default T getAndUpdateAttribute(@NotNull AttributeKey key, @NotNull Function<@Nullable T, @Nullable T> function) { return getAttributes().getAndUpdate(key, function); } + default Optional getAttibuteAsOptional(@NotNull AttributeKey key) { + return getAttributes().getAsOptional(key); + } + + @Deprecated(forRemoval = true, since = "0.2.0") default Optional getAsOptional(@NotNull AttributeKey key) { return getAttributes().getAsOptional(key); } diff --git a/src/main/java/dev/tommyjs/jobserve/observer/ObserverList.java b/src/main/java/dev/tommyjs/jobserve/observer/ObserverList.java index 342fde5..a4bb56b 100644 --- a/src/main/java/dev/tommyjs/jobserve/observer/ObserverList.java +++ b/src/main/java/dev/tommyjs/jobserve/observer/ObserverList.java @@ -1,5 +1,8 @@ package dev.tommyjs.jobserve.observer; +import dev.tommyjs.jobserve.attribute.AttributeKey; +import dev.tommyjs.jobserve.attribute.AttributeObservable; +import dev.tommyjs.jobserve.attribute.AttributeRegistry; import dev.tommyjs.jobserve.observer.key.DuplexKey; import dev.tommyjs.jobserve.observer.key.MonoKey; import org.jetbrains.annotations.NotNull; @@ -33,6 +36,12 @@ public ObserverList() { return sub; } + public @NotNull ObserverSubscription observeAttribute(@NotNull AttributeObservable object, @NotNull AttributeKey key, @NotNull Consumer consumer) { + ObserverSubscription sub = object.observeAttribute(key, consumer); + add(sub); + return sub; + } + public void add(ObserverSubscription subscription) { mutex.lock(); try {