code: public static ItemRule newInstance(String type, String name, String valueType,
                                         String defaultValue, Boolean tokenize,
                                         Boolean mandatory, Boolean secret) throws IllegalRuleException {
          ItemRule itemRule = new ItemRule();
  
          ItemType itemType = ItemType.resolve(type);
          if (type != null && itemType == null) {
              throw new IllegalRuleException("No item type for '" + type + "'");
          }
          if (itemType != null) {
              itemRule.setType(itemType);
          } else {
              itemRule.setType(ItemType.SINGLE); //default
          }
  
          if (!StringUtils.isEmpty(name)) {
              itemRule.setName(name);
          } else {
              itemRule.setAutoNamed(true);
          }
  
          if (tokenize != null) {
              itemRule.setTokenize(tokenize);
          }
  
          if (valueType != null) {
              ItemValueType itemValueType = ItemValueType.resolve(valueType);
              if (itemValueType == null) {
                  throw new IllegalRuleException("No item value type for '" + valueType + "'");
              }
              itemRule.setValueType(itemValueType);
          }
  
          if (defaultValue != null) {
              itemRule.setDefaultValue(defaultValue);
          }
  
          if (mandatory != null) {
              itemRule.setMandatory(mandatory);
          }
  
          if (secret != null) {
              itemRule.setSecret(secret);
          }
  
          return itemRule;
      }
docs: Returns a new derived instance of ItemRule.
  
  @param type the item type
  @param name the name of the item
  @param valueType the type of value an item can have
  @param defaultValue the default value used if the item has not been assigned a value or is null
  @param tokenize whether to tokenize
  @param mandatory whether or not this item is mandatory
  @param secret whether or not this item requires secure input
  @return the item rule
  @throws IllegalRuleException if an illegal rule is found