@Test public void testEquals() { LocatorIF locator = createLocator(NOTATION, ADDRESS); Assert.assertEquals("locator does not equal itself", locator, locator); Assert.assertFalse("locator equals null", locator.equals(null)); LocatorIF locator2 = createLocator("generic", ADDRESS); Assert.assertEquals("comparison of notation name not case-insensitive", locator2, locator); }
@Override public boolean equals(Object object) { try { LocatorIF locator = (LocatorIF)object; return address.equals(locator.getAddress()) && notation.equalsIgnoreCase(locator.getNotation()); } catch (ClassCastException e) { return false; } catch (NullPointerException e) { return false; } }
GenericLocator extends AbstractLocator implements Externalizable { @Override public boolean equals(Object object) { try { LocatorIF locator = (LocatorIF)object; return address.equals(locator.getAddress()) && notation.equalsIgnoreCase(locator.getNotation()); } catch (ClassCastException e) { return false; } catch (NullPointerException e) { return false; } } }
GenericLocator extends AbstractLocator implements Externalizable { @Override public boolean equals(Object object) { try { LocatorIF locator = (LocatorIF)object; return address.equals(locator.getAddress()) && notation.equalsIgnoreCase(locator.getNotation()); } catch (ClassCastException e) { return false; } catch (NullPointerException e) { return false; } } GenericLocator();  GenericLocator(String notation, String address); }
GenericLocator extends AbstractLocator implements Externalizable { @Override public boolean equals(Object object) { try { LocatorIF locator = (LocatorIF)object; return address.equals(locator.getAddress()) && notation.equalsIgnoreCase(locator.getNotation()); } catch (ClassCastException e) { return false; } catch (NullPointerException e) { return false; } } GenericLocator();  GenericLocator(String notation, String address); @Override String getNotation(); @Override String getAddress(); @Override LocatorIF resolveAbsolute(String address); @Override String getExternalForm(); @Override int hashCode(); @Override boolean equals(Object object); @Override void writeExternal(ObjectOutput out); @Override void readExternal(ObjectInput in); }
GenericLocator extends AbstractLocator implements Externalizable { @Override public boolean equals(Object object) { try { LocatorIF locator = (LocatorIF)object; return address.equals(locator.getAddress()) && notation.equalsIgnoreCase(locator.getNotation()); } catch (ClassCastException e) { return false; } catch (NullPointerException e) { return false; } } GenericLocator();  GenericLocator(String notation, String address); @Override String getNotation(); @Override String getAddress(); @Override LocatorIF resolveAbsolute(String address); @Override String getExternalForm(); @Override int hashCode(); @Override boolean equals(Object object); @Override void writeExternal(ObjectOutput out); @Override void readExternal(ObjectInput in);  }