code: public void setRestrictions(List<IRule> rulesNew) throws CDKException {
  
          Iterator<IRule> itRules = rulesNew.iterator();
          while (itRules.hasNext()) {
              IRule rule = itRules.next();
              if (rule instanceof ElementRule) {
                  mfRange = (MolecularFormulaRange) ((Object[]) rule.getParameters())[0];
  
                  //removing the rule
                  Iterator<IRule> oldRuleIt = rules.iterator();
                  while (oldRuleIt.hasNext()) {
                      IRule oldRule = oldRuleIt.next();
                      if (oldRule instanceof ElementRule) {
                          rules.remove(oldRule);
                          rules.add(rule);
                          break;
                      }
                  }
                  this.matrix_Base = getMatrix(mfRange.getIsotopeCount());
              } else if (rule instanceof ChargeRule) {
                  this.charge = (Double) ((Object[]) rule.getParameters())[0];
  
                  //removing the rule
                  Iterator<IRule> oldRuleIt = rules.iterator();
                  while (oldRuleIt.hasNext()) {
                      IRule oldRule = oldRuleIt.next();
                      if (oldRule instanceof ChargeRule) {
                          rules.remove(oldRule);
                          rules.add(rule);
                          break;
                      }
                  }
              } else if (rule instanceof ToleranceRangeRule) {
                  this.tolerance = (Double) ((Object[]) rule.getParameters())[1];
                  //removing the rule
                  Iterator<IRule> oldRuleIt = rules.iterator();
                  while (oldRuleIt.hasNext()) {
                      IRule oldRule = oldRuleIt.next();
                      if (oldRule instanceof ToleranceRangeRule) {
                          rules.remove(oldRule);
                          rules.add(rule);
                          break;
                      }
                  }
              } else {
                  rules.add(rule);
              }
  
          }
      }
docs: Set the restrictions that must be presents in the molecular formula.
  
  @param rulesNew  The restrictions to impose
  
  @see #getRestrictions()
  @see #setDefaultRestrictions()
  @see IRule