diff options
| author | Michael Williamson <mike@zwobble.org> | 2017-03-30 23:09:24 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2017-04-01 16:15:41 +0100 |
| commit | 5b174110627839214c1413255e1c6715ff7d0aab (patch) | |
| tree | 3f2a97c071f82c0e44d9846a931f813474250764 /Mammoth/Couscous/java/util/OptionalInt.cs | |
| parent | 99ed1b53f084322c06975a2183d812db5f257d34 (diff) | |
Update java-mammoth to 1.3.1
Diffstat (limited to 'Mammoth/Couscous/java/util/OptionalInt.cs')
| -rw-r--r-- | Mammoth/Couscous/java/util/OptionalInt.cs | 38 |
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; + } + } +} |
