aboutsummaryrefslogtreecommitdiff
path: root/Mammoth/Couscous/java/util/AbstractMap.cs
blob: 86e4629b889496aa4bfa522942f5ed77dbe6e920 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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 void putAll(Map<TKey, TValue> other);
        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();
    }
}