code: public static String swapCase(final String str) {
          if (N.isNullOrEmpty(str)) {
              return str;
          }
  
          final char[] cbuf = str.toCharArray();
          char ch = 0;
          for (int i = 0, len = cbuf.length; i < len; i++) {
              ch = cbuf[i];
  
              if (Character.isUpperCase(ch) || Character.isTitleCase(ch)) {
                  cbuf[i] = Character.toLowerCase(ch);
              } else if (Character.isLowerCase(ch)) {
                  cbuf[i] = Character.toUpperCase(ch);
              }
          }
  
          return newString(cbuf, true);
      }
docs: <p>
  Swaps the case of a String changing upper and title case to lower case,
  and lower case to upper case.
  </p>
  
  <ul>
  <li>Upper case character converts to Lower case</li>
  <li>Title case character converts to Lower case</li>
  <li>Lower case character converts to Upper case</li>
  </ul>
  
  <p>
  For a word based algorithm, see
  {@link org.apache.commons.lang3.text.WordUtils#swapCase(String)}. A
  {@code null} input String returns {@code null}.
  </p>
  
  <pre>
  N.swapCase(null)                 = null
  N.swapCase("")                   = ""
  N.swapCase("The dog has a BONE") = "tHE DOG HAS A bone"
  </pre>
  
  <p>
  NOTE: This method changed in Lang version 2.0. It no longer performs a
  word based algorithm. If you only use ASCII, you will notice no change.
  That functionality is available in
  org.apache.commons.lang3.text.WordUtils.
  </p>
  
  @param str
  the String to swap case, may be null
  @return the changed String, {@code null} if null String input