@Contract(pure = true)
  public static @Unmodifiable @NotNull List<CharSequence> split(@NotNull CharSequence s,
                                                                @NotNull CharFilter separator,
                                                                boolean excludeSeparator,
                                                                boolean excludeEmptyStrings) {
    List<CharSequence> result = new ArrayList<>();
    int pos = 0;
    int index = 0;
    while (index < s.length()) {
      if (separator.accept(s.charAt(index))) {
        CharSequence token = s.subSequence(pos, excludeSeparator ? index : index + 1);
        if (token.length() != 0 || !excludeEmptyStrings) {
          result.add(token);
        }
        pos = index + 1;
      }
      index++;
    }
    if (pos < s.length() || !excludeEmptyStrings && pos == s.length()) {
      result.add(s.subSequence(pos, s.length()));
    }
    return result;
  }
@Contract(pure = true)
  public static @Unmodifiable @NotNull List<CharSequence> split(@NotNull CharSequence s,
                                                                @NotNull CharFilter separator,
                                                                boolean excludeSeparator,
                                                                boolean excludeEmptyStrings)