aboutsummaryrefslogtreecommitdiff
path: root/Mammoth/Couscous/java/util/OptionalInt.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Mammoth/Couscous/java/util/OptionalInt.cs')
-rw-r--r--Mammoth/Couscous/java/util/OptionalInt.cs38
1 files changed, 38 insertions, 0 deletions
diff --git a/Mammoth/Couscous/java/util/OptionalInt.cs b/Mammoth/Couscous/java/util/OptionalInt.cs
new file mode 100644
index 0000000..4dfca2f
--- /dev/null
+++ b/Mammoth/Couscous/java/util/OptionalInt.cs
@@ -0,0 +1,38 @@
+using Mammoth.Couscous.java.util.function;
+
+namespace Mammoth.Couscous.java.util
+{
+ internal interface OptionalInt
+ {
+ bool isPresent();
+ int getAsInt();
+ }
+
+ internal struct NoneInt : OptionalInt {
+ internal static readonly NoneInt Instance = new NoneInt();
+
+ public bool isPresent() {
+ return false;
+ }
+
+ public int getAsInt() {
+ throw new NoSuchElementException();
+ }
+ }
+
+ internal struct SomeInt : OptionalInt {
+ private readonly int _value;
+
+ internal SomeInt(int value) {
+ _value = value;
+ }
+
+ public bool isPresent() {
+ return true;
+ }
+
+ public int getAsInt() {
+ return _value;
+ }
+ }
+}