code: private String normalizeText(String text) {
          String[] tokens = StringUtils.split(text, "\n");
          for (int i = 0; i < tokens.length; i++) {
              tokens[i] = tokens[i].trim();
          }
  
          return StringUtils.join(tokens, " ").trim();
      }
docs: Remove trailing whitespaces and new line characters
  
  @param text
  @return