CombinedAtomicMassNumberRule implements ISequenceSubRule<ILigand> { @Override public int compare(ILigand ligand1, ILigand ligand2) { int atomicNumberComp = atomicNumberRule.compare(ligand1, ligand2); if (atomicNumberComp != 0) return atomicNumberComp; int massNumberComp = massNumberRule.compare(ligand1, ligand2); if (massNumberComp != 0) return massNumberComp; if ("H".equals(ligand1.getLigandAtom().getSymbol())) { return 0; } return massNumberComp; }  @Override int compare(ILigand ligand1, ILigand ligand2);  }
@Test public void testCompare_Identity() { ILigand ligand = new Ligand(molecule, new VisitedAtoms(), molecule.getAtom(1), molecule.getAtom(0)); ISequenceSubRule<ILigand> rule = new CombinedAtomicMassNumberRule(); Assert.assertEquals(0, rule.compare(ligand, ligand)); }
@Test public void testCompare() { ILigand ligand1 = new Ligand(molecule, new VisitedAtoms(), molecule.getAtom(1), molecule.getAtom(0)); ILigand ligand2 = new Ligand(molecule, new VisitedAtoms(), molecule.getAtom(1), molecule.getAtom(2)); ISequenceSubRule<ILigand> rule = new CombinedAtomicMassNumberRule(); Assert.assertEquals(-1, rule.compare(ligand1, ligand2)); Assert.assertEquals(1, rule.compare(ligand2, ligand1)); }