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/AbstractMap.cs | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Mammoth/Couscous/java/util/AbstractMap.cs (limited to 'Mammoth/Couscous/java/util/AbstractMap.cs') diff --git a/Mammoth/Couscous/java/util/AbstractMap.cs b/Mammoth/Couscous/java/util/AbstractMap.cs new file mode 100644 index 0000000..f619267 --- /dev/null +++ b/Mammoth/Couscous/java/util/AbstractMap.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using System.Linq; +using Mammoth.Couscous.java.lang; + +namespace Mammoth.Couscous.java.util { + internal abstract class AbstractMap : Map { + public override bool Equals(object other) { + var otherMap = other as Map; + if (otherMap == null) { + return false; + } else { + return Equals(otherMap); + } + } + + public bool Equals(Map other) { + var first = AsUntypedDictionary(); + var second = other.AsUntypedDictionary(); + return + first.Count == second.Count && + first.Keys.Cast().All(key => second.Contains(key) && first[key].Equals(second[key])); + } + + public override int GetHashCode() { + throw new System.NotSupportedException(); + } + + public abstract void put(TKey key, TValue value); + public abstract bool containsKey(TKey key); + public abstract Set> entrySet(); + public abstract Collection values(); + + public abstract Optional _lookup(TKey key); + public abstract System.Collections.Generic.IDictionary AsDictionary(); + public abstract System.Collections.IDictionary AsUntypedDictionary(); + } +} -- cgit v1.2.3