if (this.priority == that.priority) { final Set<FactoryComparator> comparators = new HashSet<FactoryComparator>(); return new FactoryComparator(this, that).compare(comparators);
/** * Returns {@code true} if {@code f1} and {@code f2} are equals. * * @param done An initially empty set. Used internally for preventing infinite recursivity. */ boolean compare(final Set<FactoryComparator> done) { if (done.add(this)) { final Map<RenderingHints.Key, ?> m1 = f1.getImplementationHints(); final Map<RenderingHints.Key, ?> m2 = f2.getImplementationHints(); if (m1.size() != m2.size()) { return false; } for (final Map.Entry<RenderingHints.Key, ?> entry : m1.entrySet()) { final Object key = entry.getKey(); final Object v1 = entry.getValue(); final Object v2 = m2.get(key); if (v1 == v2) continue; if (v1 instanceof Factory) { if (v2 == null || !v1.getClass().equals(v2.getClass()) || !new FactoryComparator((Factory) v1, (Factory) v2).compare(done)) { return false; } } else if (!Utilities.equals(v1, v2)) { return false; } } } return true; }