ChemObjectDiff { public static IDifference difference(IChemObject first, IChemObject second) { if (!(first instanceof IChemObject && second instanceof IChemObject)) { return null; } IChemObject firstElem = (IChemObject) first; IChemObject secondElem = (IChemObject) second; ChemObjectDifference coDiff = new ChemObjectDifference("ChemObjectDiff"); boolean[] firstFlags = firstElem.getFlags(); boolean[] secondFlags = secondElem.getFlags(); coDiff.addChild(BooleanArrayDifference.construct("flag", firstFlags, secondFlags)); if (coDiff.childCount() > 0) { return coDiff; } else { return null; } } private  ChemObjectDiff(); static String diff(IChemObject first, IChemObject second); static IDifference difference(IChemObject first, IChemObject second);  }
@Test public void testDifference() { IChemObject atom1 = mock(IChemObject.class); IChemObject atom2 = mock(IChemObject.class); when(atom1.getFlags()).thenReturn(new boolean[]{false, false, false}); when(atom2.getFlags()).thenReturn(new boolean[]{false, true, false}); IDifference difference = ChemObjectDiff.difference(atom1, atom2); Assert.assertNotNull(difference); }