ChargeRule implements IRule { @Override public void setParameters(Object[] params) throws CDKException { if (params.length != 1) throw new CDKException("ChargeRule expects only one parameter"); if (!(params[0] instanceof Double)) throw new CDKException("The parameter must be of type Double"); charge = (Double) params[0]; } ChargeRule(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override double validate(IMolecularFormula formula);  }
@Test public void testSetParameters() throws ClassNotFoundException, CDKException, Exception { IRule rule = new ChargeRule(); Object[] params = new Object[1]; params[0] = -1.0; rule.setParameters(params); Object[] objects = rule.getParameters(); Assert.assertEquals(1, objects.length); double charge = (Double) objects[0]; Assert.assertEquals(-1.0, charge, 0.00001); }