/** * Compares an Element with this Element. * * @param object Object of type AtomType * @return true if the atom types are equal */ @Override public boolean compare(Object object) { if (!(object instanceof Element)) { return false; } if (!super.compare(object)) { return false; } Element elem = (Element) object; return Objects.equal(atomicNumber, elem.atomicNumber); } }
/** * Compares an Element with this Element. * * @param object Object of type AtomType * @return true if the atom types are equal */ @Override public boolean compare(Object object) { if (!(object instanceof Element)) { return false; } if (!super.compare(object)) { return false; } Element elem = (Element) object; return Objects.equal(atomicNumber, elem.atomicNumber); } }
@Test public void compare() { ChemObject co1 = new ChemObject(); ChemObject co2 = new ChemObject(); co1.setID(new String("a1")); co2.setID(new String("a1")); Assert.assertTrue(co1.compare(co2)); }
@Test public void compareDifferent() { ChemObject co1 = new ChemObject(); ChemObject co2 = new ChemObject(); co1.setID(new String("a1")); co2.setID(new String("a2")); Assert.assertFalse(co1.compare(co2)); } }