aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io')
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableProperty.java10
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/data/ObservableView.java13
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