Here you can find the source of mapEquals(Map
public static <K, V> boolean mapEquals(Map<K, V> a, Object b)
//package com.java2s; //License from project: Open Source License import java.util.*; import java.util.Map.Entry; public class Main { public static <K, V> boolean mapEquals(Map<K, V> a, Object b) { if (a == b) return true; if (b == null || a == null) return false; if (!(b instanceof Map)) return false; Map<?, ?> t = (Map<?, ?>) b; if (a.size() != t.size()) return false; try {/*from ww w. j a v a 2 s . c om*/ for (Entry<K, V> e : a.entrySet()) { K key = e.getKey(); V value = e.getValue(); if (value == null) { if (!(t.get(key) == null && t.containsKey(key))) return false; } else { if (!value.equals(t.get(key))) return false; } } } catch (ClassCastException unused) { return false; } catch (NullPointerException unused) { return false; } return true; } }