ElementRule implements IRule { @Override public void setParameters(Object[] params) throws CDKException { if (params.length != 1) throw new CDKException("ElementRule expects one parameters"); if (!(params[0] == null || params[0] instanceof MolecularFormulaRange)) throw new CDKException("The parameter must be of type MolecularFormulaExpand"); mfRange = (MolecularFormulaRange) params[0]; } ElementRule(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override double validate(IMolecularFormula formula);  }
@Test public void testSetParameters() throws Exception { IRule rule = new ElementRule(); Object[] params = new Object[1]; MolecularFormulaRange mfRange = new MolecularFormulaRange(); mfRange.addIsotope(builder.newInstance(IIsotope.class, "C"), 1, 10); mfRange.addIsotope(builder.newInstance(IIsotope.class, "H"), 1, 10); params[0] = mfRange; rule.setParameters(params); Object[] objects = rule.getParameters(); Assert.assertEquals(1, objects.length); MolecularFormulaRange mfRange2 = (MolecularFormulaRange) objects[0]; Assert.assertEquals(mfRange.getIsotopeCount(), mfRange2.getIsotopeCount()); Assert.assertEquals(mfRange.getIsotopeCountMin(new Isotope("C")), mfRange2.getIsotopeCountMin(new Isotope("C"))); Assert.assertEquals(mfRange.getIsotopeCountMax(new Isotope("C")), mfRange2.getIsotopeCountMax(new Isotope("C"))); }