@Test public void testEquals() { final Key key1 = new Key(1 ); final Key key2 = new Key(2 ); final Key key3 = new Key(3 ); final Key key3_reference_f1 = new Key(31); final Key key2_reference_f3 = new Key(23); final Key key1_reference_f2 = new Key(12); final AbstractFactory f1 = new AbstractFactory(); final AbstractFactory f2 = new AbstractFactory(); final AbstractFactory f3 = new AbstractFactory(); f1.hints.put(key1, "Value 1"); f2.hints.put(key2, "Value 2"); f3.hints.put(key3_reference_f1, f1); f2.hints.put(key2_reference_f3, f3); f1.hints.put(key1_reference_f2, f2); assertFalse(f1.toString().length() == 0); assertEquals(f1, f1); assertEquals(f2, f2); assertEquals(f3, f3); assertFalse (f1.equals(f2)); assertFalse (f1.equals(f3)); assertFalse (f2.equals(f3)); final AbstractFactory f1b = new AbstractFactory(); final AbstractFactory f2b = new AbstractFactory(); final AbstractFactory f3b = new AbstractFactory(); f1b.hints.put(key1, "Value 1"); f2b.hints.put(key2, "Value 2"); f3b.hints.put(key3_reference_f1, f1b); f2b.hints.put(key2_reference_f3, f3b); f1b.hints.put(key1_reference_f2, f2b); assertEquals(f2, f2b); f1b.hints.put(key1, "Different value"); assertFalse(f2.equals(f2b)); }
@Override public final boolean equals(final Object object) { if (object == this) { return true; } if (object!=null && object.getClass().equals(getClass())) { final AbstractFactory that = (AbstractFactory) object; if (this.priority == that.priority) { final Set<FactoryComparator> comparators = new HashSet<FactoryComparator>(); return new FactoryComparator(this, that).compare(comparators); } } return false; }
AbstractFactory implements Factory, RegisterableService { @Override public final boolean equals(final Object object) { if (object == this) { return true; } if (object!=null && object.getClass().equals(getClass())) { final AbstractFactory that = (AbstractFactory) object; if (this.priority == that.priority) { final Set<FactoryComparator> comparators = new HashSet<FactoryComparator>(); return new FactoryComparator(this, that).compare(comparators); } } return false; } }
AbstractFactory implements Factory, RegisterableService { @Override public final boolean equals(final Object object) { if (object == this) { return true; } if (object!=null && object.getClass().equals(getClass())) { final AbstractFactory that = (AbstractFactory) object; if (this.priority == that.priority) { final Set<FactoryComparator> comparators = new HashSet<FactoryComparator>(); return new FactoryComparator(this, that).compare(comparators); } } return false; } protected  AbstractFactory(); protected  AbstractFactory(final int priority); }
AbstractFactory implements Factory, RegisterableService { @Override public final boolean equals(final Object object) { if (object == this) { return true; } if (object!=null && object.getClass().equals(getClass())) { final AbstractFactory that = (AbstractFactory) object; if (this.priority == that.priority) { final Set<FactoryComparator> comparators = new HashSet<FactoryComparator>(); return new FactoryComparator(this, that).compare(comparators); } } return false; } protected  AbstractFactory(); protected  AbstractFactory(final int priority); int getPriority(); Map<RenderingHints.Key, ?> getImplementationHints(); void onRegistration(final ServiceRegistry registry, final Class category); void onDeregistration(final ServiceRegistry registry, final Class category); @Override final int hashCode(); @Override final boolean equals(final Object object); @Override String toString(); }
AbstractFactory implements Factory, RegisterableService { @Override public final boolean equals(final Object object) { if (object == this) { return true; } if (object!=null && object.getClass().equals(getClass())) { final AbstractFactory that = (AbstractFactory) object; if (this.priority == that.priority) { final Set<FactoryComparator> comparators = new HashSet<FactoryComparator>(); return new FactoryComparator(this, that).compare(comparators); } } return false; } protected  AbstractFactory(); protected  AbstractFactory(final int priority); int getPriority(); Map<RenderingHints.Key, ?> getImplementationHints(); void onRegistration(final ServiceRegistry registry, final Class category); void onDeregistration(final ServiceRegistry registry, final Class category); @Override final int hashCode(); @Override final boolean equals(final Object object); @Override String toString(); static final int MINIMUM_PRIORITY; static final int NORMAL_PRIORITY; static final int MAXIMUM_PRIORITY; }