aboutsummaryrefslogtreecommitdiff
path: root/Mammoth/Couscous/java/util/AbstractMap.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Mammoth/Couscous/java/util/AbstractMap.cs')
-rw-r--r--Mammoth/Couscous/java/util/AbstractMap.cs37
1 files changed, 37 insertions, 0 deletions
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<TKey, TValue> : Map<TKey, TValue> {
+ 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<object>().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<Map__Entry<TKey, TValue>> entrySet();
+ public abstract Collection<TValue> values();
+
+ public abstract Optional<TValue> _lookup(TKey key);
+ public abstract System.Collections.Generic.IDictionary<TKey, TValue> AsDictionary();
+ public abstract System.Collections.IDictionary AsUntypedDictionary();
+ }
+}