class MustacheStringUtils {

  public static String removeLastWhitespaceLine(final String str) {
    if (str == null) {
      return "";
    }

    int end = str.length();
    if (end == 0) {
      return "";
    }

    while (end != 0) {
      char c = str.charAt(end - 1);
      if (!Character.isWhitespace(c)) {
        return str;
      }

      if ('\r' == c || '\n' == c) {
        return str.substring(0, end);
      }

      end--;
    }

    return "";
  }

  private  MustacheStringUtils();

}