MolecularFormulaRange implements Cloneable { public void addIsotope(IIsotope isotope, int countMin, int countMax) { if (isotope == null) throw new IllegalArgumentException("Isotope must not be null"); boolean flag = false; for (Iterator<IIsotope> it = isotopes().iterator(); it.hasNext();) { IIsotope thisIsotope = it.next(); if (isTheSame(thisIsotope, isotope)) { isotopesMax.put(thisIsotope, countMax); isotopesMin.put(thisIsotope, countMin); flag = true; break; } } if (!flag) { isotopesMax.put(isotope, countMax); isotopesMin.put(isotope, countMin); } } 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(expected=IllegalArgumentException.class) public void testNull() throws Exception { MolecularFormulaRange mfRange = new MolecularFormulaRange(); IIsotope carb = builder.newInstance(IIsotope.class, "C"); IIsotope nul = null; mfRange.addIsotope(carb, 2, 5); mfRange.addIsotope(nul, 3, 7); }