MolecularFormulaRange implements Cloneable { public Iterable<IIsotope> isotopes() { return new Iterable<IIsotope>() { @Override public Iterator<IIsotope> iterator() { return isotopesMax.keySet().iterator(); } }; } MolecularFormulaRange(); void addIsotope(IIsotope isotope, int countMin, int countMax); boolean contains(IIsotope isotope); int getIsotopeCountMax(IIsotope isotope); int getIsotopeCountMin(IIsotope isotope); int getIsotopeCount(); Iterable<IIsotope> isotopes(); void removeAllIsotopes(); void removeIsotope(IIsotope isotope); @Override Object clone();  }
@Test public void testIsotopes() { MolecularFormulaRange mfRange = new MolecularFormulaRange(); mfRange.addIsotope(builder.newInstance(IIsotope.class, "C"), 0, 10); mfRange.addIsotope(builder.newInstance(IIsotope.class, "F"), 0, 10); Iterator<IIsotope> istoIter = mfRange.isotopes().iterator(); int counter = 0; while (istoIter.hasNext()) { istoIter.next(); counter++; } Assert.assertEquals(2, counter); }