code: public static boolean hasMoreCodePointsThan(StringBuffer source, int number) {
          if (number < 0) {
              return true;
          }
          if (source == null) {
              return false;
          }
          int length = source.length();
  
          // length >= 0 known
          // source contains at least (length + 1) / 2 code points: <= 2
          // chars per cp
          if (((length + 1) >> 1) > number) {
              return true;
          }
  
          // check if source does not even contain enough chars
          int maxsupplementary = length - number;
          if (maxsupplementary <= 0) {
              return false;
          }
  
          // there are maxsupplementary = length - number more chars than
          // asked-for code points
  
          // count code points until they exceed and also check that there are
          // no more than maxsupplementary supplementary code points (char pairs)
          int start = 0;
          while (true) {
              if (length == 0) {
                  return false;
              }
              if (number == 0) {
                  return true;
              }
              if (isLeadSurrogate(source.charAt(start++)) && start != length
                      && isTrailSurrogate(source.charAt(start))) {
                  start++;
                  if (--maxsupplementary <= 0) {
                      // too many pairs - too few code points
                      return false;
                  }
              }
              --number;
          }
      }
docs: Check if the string buffer contains more Unicode code points than a certain number. This is
  more efficient than counting all code points in the entire string buffer and comparing that
  number with a threshold. This function may not need to scan the string buffer at all if the
  length is within a certain range, and never needs to count more than 'number + 1' code
  points. Logically equivalent to (countCodePoint(s) &gt; number). A Unicode code point may
  occupy either one or two code units.
  
  @param source The input string buffer.
  @param number The number of code points in the string buffer is compared against the 'number'
  parameter.
  @return boolean value for whether the string buffer contains more Unicode code points than
  'number'.