code: public String normalizeWhitespace(String value) {
          String result = null;
          if (value != null) {
              value = value.trim();
              result = replaceAllInWith("\\s+", value, " ");
          }
          return result;
      }
docs: Trims value and replaces all (sequences of) whitespace to a single space.
  @param value value to clean up.
  @return trimmed value with all whitespace converted to single space.