We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0496e89 commit dca2b0cCopy full SHA for dca2b0c
1 file changed
src/main/java/gentle/Result.java
@@ -45,6 +45,28 @@ default Optional<T> asOptional() {
45
};
46
}
47
48
+ /**
49
+ * Returns whether this {@code Result} represents an error.
50
+ * <p>
51
+ * Equivalent to checking {@code instanceOf Err}.
52
+ *
53
+ * @return {@code true} if this is an {@link Err}, otherwise {@code false}
54
+ */
55
+ default boolean isError() {
56
+ return this instanceof Err<T,E>;
57
+ }
58
+
59
60
+ * Returns whether this {@code Result} represents a successful value.
61
62
+ * Equivalent to checking {@code instanceOf Ok}.
63
64
+ * @return {@code true} if this is an {@link Ok}, otherwise {@code false}
65
66
+ default boolean isOk() {
67
+ return this instanceof Ok<T,E>;
68
69
70
/**
71
* Transforms the success value using the given function, leaving errors unchanged.
72
*
0 commit comments