code: protected void addFormParam(Form formData, String name, Object value, boolean required) throws IllegalArgumentException {
  
          if (value == null) {
  
              if (required) {
                  throw new IllegalArgumentException(name + " cannot be empty or null");
              }
  
              return;
          }
  
          String stringValue = value.toString();
          if (required && stringValue.trim().length() == 0) {
              throw new IllegalArgumentException(name + " cannot be empty or null");
          }
  
          formData.param(name, stringValue);
      }
docs: Convenience method for adding query and form parameters to a get() or post() call.
  If required is true and value is null, will throw an IllegalArgumentException.
  
  @param formData the Form containing the name/value pairs
  @param name the name of the field/attribute to add
  @param value the value of the field/attribute to add
  @param required the field is required flag
  @throws IllegalArgumentException if a required parameter is null or empty