From 5b174110627839214c1413255e1c6715ff7d0aab Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 30 Mar 2017 23:09:24 +0100 Subject: Update java-mammoth to 1.3.1 --- Mammoth/Couscous/java/util/OptionalInt.cs | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Mammoth/Couscous/java/util/OptionalInt.cs (limited to 'Mammoth/Couscous/java/util/OptionalInt.cs') 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; + } + } +} -- cgit v1.2.3