class NpmSearchParameterExtractor extends ComponentSupport {

  public int extractSize(final Parameters parameters) {
    int size = 20;
    String sizeParameter = Strings.nullToEmpty(parameters.get("size")).trim();
    if (!sizeParameter.isEmpty()) {
      try {
        size = Integer.parseInt(sizeParameter);
      }
      catch (NumberFormatException e) {
        log.debug("Invalid size encountered in search parameters {}, using default", parameters, e);
      }
      if (size < 1) {
        size = 1;
      }
      else if (size > 250) {
        size = 250;
      }
    }
    return size;
  }

}