ToleranceRangeRule implements IRule { @Override public void setParameters(Object[] params) throws CDKException { if (params.length > 2) throw new CDKException("ToleranceRangeRule expects only two parameter"); if (!(params[0] instanceof Double)) throw new CDKException("The parameter 0 must be of type Double"); if (!(params[1] instanceof Double)) throw new CDKException("The parameter 1 must be of type Double"); mass = (Double) params[0]; tolerance = (Double) params[1]; } ToleranceRangeRule(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override double validate(IMolecularFormula formula);  }
@Test public void testSetParameters() throws Exception { IRule rule = new ToleranceRangeRule(); Object[] params = new Object[2]; params[0] = 133.0; params[1] = 0.00005; rule.setParameters(params); Object[] objects = rule.getParameters(); Assert.assertEquals(2, objects.length); double mass = (Double) objects[0]; Assert.assertEquals(133.0, mass, 0.00001); double tolerance = (Double) objects[1]; Assert.assertEquals(0.00005, tolerance, 0.00001); }