boolean (Object obj) { if (!(obj instanceof Map)) return false; Map<?, ?> map = (Map<?, ?>)obj; if (size() != map.size()) return false; if (k1 != null) { if (!Objects.equals(map.get(k1), v1)) return false; if (k2 != null) { if (!Objects.equals(map.get(k2), v2)) return false; if (k3 != null && !Objects.equals(map.get(k3), v3)) return false; } } for (int i = 0; i < data.length; i += 2) { @SuppressWarnings("unchecked") K key = (K)data[i]; if (key != null && !Objects.equals(map.get(key), data[i + 1])) return false; } return true; }