MMElementRule implements IRule { @Override public void setParameters(Object[] params) throws CDKException { if (params.length > 2) throw new CDKException("MMElementRule only expects maximal two parameters"); if (params[0] != null) { if (!(params[0] instanceof Database)) throw new CDKException("The parameter must be of type Database enum"); databaseUsed = (Database) params[0]; } if (params.length > 1 && params[1] != null) { if (!(params[1] instanceof RangeMass)) throw new CDKException("The parameter must be of type RangeMass enum"); rangeMassUsed = (RangeMass) params[1]; } if ((databaseUsed == Database.DNP) && (rangeMassUsed == RangeMass.Minus500)) this.hashMap = getDNP_500(); else if ((databaseUsed == Database.DNP) && (rangeMassUsed == RangeMass.Minus1000)) this.hashMap = getDNP_1000(); else if ((databaseUsed == Database.DNP) && (rangeMassUsed == RangeMass.Minus2000)) this.hashMap = getDNP_2000(); else if ((databaseUsed == Database.DNP) && (rangeMassUsed == RangeMass.Minus3000)) this.hashMap = getDNP_3000(); else if ((databaseUsed == Database.WILEY) && (rangeMassUsed == RangeMass.Minus500)) this.hashMap = getWisley_500(); else if ((databaseUsed == Database.WILEY) && (rangeMassUsed == RangeMass.Minus1000)) this.hashMap = getWisley_1000(); else if ((databaseUsed == Database.WILEY) && (rangeMassUsed == RangeMass.Minus2000)) this.hashMap = getWisley_2000(); } MMElementRule(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override double validate(IMolecularFormula formula);  }
@Test public void testSetParameters() throws Exception { IRule rule = new MMElementRule(); Object[] params = new Object[2]; params[0] = MMElementRule.Database.DNP; params[1] = MMElementRule.RangeMass.Minus1000; rule.setParameters(params); Object[] objects = rule.getParameters(); Assert.assertSame(MMElementRule.Database.DNP, objects[0]); Assert.assertSame(MMElementRule.RangeMass.Minus1000, objects[1]); }