diff options
author | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-09-10 21:20:16 +0300 |
---|---|---|
committer | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-09-10 21:20:16 +0300 |
commit | d37bd5259adb79e2043cf63bb0e3578418531952 (patch) | |
tree | fbf5f7599f252cd3022279451a1fd55c6237043a | |
parent | db9201126dcd6b33523285ff601548dc43882075 (diff) | |
download | LibGui-d37bd5259adb79e2043cf63bb0e3578418531952.tar.gz LibGui-d37bd5259adb79e2043cf63bb0e3578418531952.tar.bz2 LibGui-d37bd5259adb79e2043cf63bb0e3578418531952.zip |
Add ObservableView.hasValue
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableProperty.java | 10 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableView.java | 13 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableProperty.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableProperty.java index 778f431..49dbf9f 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableProperty.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableProperty.java @@ -40,9 +40,7 @@ public final class ObservableProperty<T> implements ObservableView<T> { return new ObservableProperty<>(initialValue, true); } - /** - * {@return whether this property has been set to a value} - */ + @Override public boolean hasValue() { return hasValue; } @@ -51,6 +49,7 @@ public final class ObservableProperty<T> implements ObservableView<T> { * {@return the value of this property} * @throws IllegalStateException if not initialized * @throws NullPointerException if the value is null and null values aren't allowed + * @see #hasValue() */ @Override public T get() { @@ -116,6 +115,11 @@ public final class ObservableProperty<T> implements ObservableView<T> { // Missing delegates from Kotlin... :( return new ObservableView<>() { @Override + public boolean hasValue() { + return ObservableProperty.this.hasValue(); + } + + @Override public T get() { return ObservableProperty.this.get(); } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableView.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableView.java index 8439e80..164f51b 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableView.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableView.java @@ -15,6 +15,19 @@ import java.util.function.Supplier; @ApiStatus.Experimental public interface ObservableView<T> extends Supplier<T> { /** + * {@return whether this property has been set to a value} + */ + boolean hasValue(); + + /** + * {@return the value of this property} + * @throws IllegalStateException if not initialized + * @see #hasValue() + */ + @Override + T get(); + + /** * Adds a change listener to this property view. * * @param listener the added listener |