Skip to content

Commit

Permalink
release 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyskeff committed Dec 27, 2023
1 parent 9ff33a1 commit dfd665a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<repositories>
Expand All @@ -32,7 +32,7 @@ We are currently on version `0.1.1`.
<dependency>
<groupId>dev.tommyjs</groupId>
<artifactId>JObserve</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.tommyjs</groupId>
<artifactId>JObserve</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>

<properties>
<maven.compiler.source>20</maven.compiler.source>
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/dev/tommyjs/jobserve/attribute/AttributeHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,20 @@ default <T> void setAttribute(@NotNull AttributeKey<T> key, @Nullable T value) {
return getAttributes().getAttributeOrSetDefault(key, supplier);
}

default <T> T getAttributeAndUpdate(@NotNull AttributeKey<T> key, @NotNull Function<@Nullable T, @Nullable T> function) {
return getAttributes().getAndUpdate(key, function);
}

@Deprecated(forRemoval = true, since = "0.2.0")
default <T> T getAndUpdateAttribute(@NotNull AttributeKey<T> key, @NotNull Function<@Nullable T, @Nullable T> function) {
return getAttributes().getAndUpdate(key, function);
}

default <T> Optional<T> getAttibuteAsOptional(@NotNull AttributeKey<T> key) {
return getAttributes().getAsOptional(key);
}

@Deprecated(forRemoval = true, since = "0.2.0")
default <T> Optional<T> getAsOptional(@NotNull AttributeKey<T> key) {
return getAttributes().getAsOptional(key);
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/dev/tommyjs/jobserve/observer/ObserverList.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -33,6 +36,12 @@ public ObserverList() {
return sub;
}

public @NotNull <T> ObserverSubscription observeAttribute(@NotNull AttributeObservable object, @NotNull AttributeKey<T> key, @NotNull Consumer<T> consumer) {
ObserverSubscription sub = object.observeAttribute(key, consumer);
add(sub);
return sub;
}

public void add(ObserverSubscription subscription) {
mutex.lock();
try {
Expand Down

0 comments on commit dfd665a

Please sign in to comment.