@Contract(pure = true)
  public static @NotNull String trim(@NotNull String s, @NotNull CharFilter filter) {
    int start = 0;
    int end = s.length();

    for (; start < end; start++) {
      char ch = s.charAt(start);
      if (filter.accept(ch)) break;
    }

    for (; start < end; end--) {
      char ch = s.charAt(end - 1);
      if (filter.accept(ch)) break;
    }

    return s.substring(start, end);
  }
@Contract(pure = true)
  public static @NotNull String trim(@NotNull String s, @NotNull CharFilter filter)