/** * Compare two maps. * * @deprecated use {@link #eqObj(Object, Object)} or {@link java.util.Map#equals(Object)} */ public static boolean eqMap(Map<?, ?> as, Map<?, ?> bs) { for (Map.Entry<?, ?> ae : as.entrySet()) { final Object bv = bs.get(ae.getKey()); if (bv == null || !eqObj(ae.getValue(), bv)) return false; } return true; }
/** * Compare the elements of two lists one by one. * * @deprecated use {@link #eqObj(Object, Object)} or {@link java.util.List#equals(Object)} */ public static boolean eqListSorted(List<?> as, List<?> bs) { if (as != null && bs != null && as.size() == bs.size()) { final Iterator<?> asi = as.iterator(); final Iterator<?> bsi = bs.iterator(); while (asi.hasNext() && bsi.hasNext()) { if (!asi.next().equals(bsi.next())) return false; } return true; } else { return eqObj(as, bs); } }
/** * Compare the (distinct) elements of two lists for equality treating the lists as sets. * <p> * Sets by definition do not allow multiplicity of elements; a set is a (possibly empty) collection of distinct elements. * As Lists may contain non-unique entries, this method removes duplicates before continuing with the comparison check. * * Examples of * 1. equality: {1, 2} = {2, 1} = {1, 1, 2} = {1, 2, 2, 1, 2}, null = null * 2. unequal: {1, 2, 2} != {1, 2, 3}, null != {} */ public static boolean eqListUnsorted(List<?> as, List<?> bs) { if (as == null || bs == null) { return eqObj(as, bs); } as = as.stream().distinct().collect(Collectors.toList()); bs = bs.stream().distinct().collect(Collectors.toList()); if (as.size() != bs.size()) { return false; } for (Object a : as) { if (!bs.contains(a)) { return false; } } return true; }
private boolean eqFields(ConfiguredWorkflowRef that) { return eqObj(getWorkflowId(), that.getWorkflowId()) && eqMap(getParameters(), that.getParameters()); }