/** * Compare two {@link IChemObject} classes and return the difference as an {@link IDifference}. * * @param first the first of the two classes to compare * @param second the second of the two classes to compare * @return an {@link IDifference} representation of the difference between the first and second {@link IChemObject}. */ public static IDifference difference(IChemObject first, IChemObject second) { if (!(first instanceof IElement && second instanceof IElement)) { return null; } IElement firstElem = (IElement) first; IElement secondElem = (IElement) second; ChemObjectDifference coDiff = new ChemObjectDifference("ElementDiff"); coDiff.addChild(StringDifference.construct("S", firstElem.getSymbol(), secondElem.getSymbol())); coDiff.addChild(StringDifference.construct("ID", firstElem.getID(), secondElem.getID())); coDiff.addChild(IntegerDifference.construct("AN", firstElem.getAtomicNumber(), secondElem.getAtomicNumber())); coDiff.addChild(ChemObjectDiff.difference(first, second)); if (coDiff.childCount() > 0) { return coDiff; } else { return null; } }