@Override
  @SuppressWarnings("unchecked")
  public @NotNull B mapChildren(final @NotNull Function<BuildableComponent<?, ?>, ? extends BuildableComponent<?, ?>> function) {
    if (this.children == Collections.<Component>emptyList()) {
      return (B) this;
    }
    final ListIterator<Component> it = this.children.listIterator();
    while (it.hasNext()) {
      final Component child = it.next();
      if (!(child instanceof BuildableComponent<?, ?>)) {
        continue;
      }
      final BuildableComponent<?, ?> mappedChild = requireNonNull(function.apply((BuildableComponent<?, ?>) child), "mappedChild");
      if (child == mappedChild) {
        continue;
      }
      it.set(mappedChild);
    }
    return (B) this;
  }
An abstract implementation of a component builder.

@param <C> the component type
@param <B> the builder type
api/src/main/java/net/kyori/adventure/text/AbstractComponentBuilder.java