package net.ranides.test.mockup.collection;

import java.util.Comparator;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

public class SafeTreeMap<K, V> extends TreeMap<K, V> {
    public SafeTreeMap() {
    }

    public SafeTreeMap(Comparator<? super K> comparator) {
        super(comparator);
    }

    public SafeTreeMap(Map<? extends K, ? extends V> m) {
        super(m);
    }

    public SafeTreeMap(SortedMap<K, ? extends V> m) {
        super(m);
    }

    @Override
    public boolean containsKey(Object key) {
        try {
            return super.containsKey(key);
        } catch (ClassCastException e) {
            return false;
        }
    }

    @Override
    public V get(Object key) {
        try {
            return super.get(key);
        } catch (ClassCastException e) {
            return null;
        }
    }

    @Override
    public V remove(Object key) {
        try {
            return super.remove(key);
        } catch (ClassCastException e) {
            return null;
        }
    }
}
