code: public static String sanitizeWhitespace(String input) {
  
  		Assert.notNull(input, "Missing input!");
  		input = input.replaceAll("\\s+", " ");
  		return input.trim();
  	}
docs: Removes all multiple-consecutive whitespace characters (space, tab, newline) and replaces them with single space.
  Also removes leading and trailing spaces.
  
  @param input to be sanitized
  @return sanitized output
  
  @throws IllegalArgumentException in case input is null or empty