static @NotNull List<Component> asComponents(final @NotNull List<? extends ComponentLike> likes, final @Nullable Predicate<? super Component> filter) {
    requireNonNull(likes, "likes");
    final int size = likes.size();
    if (size == 0) {
      // We do not need to create a new list if the one we are copying is empty - we can
      // simply just return our known-empty list instead.
      return Collections.emptyList();
    }
    @Nullable ArrayList<Component> components = null;
    for (int i = 0; i < size; i++) {
      final @Nullable ComponentLike like = likes.get(i);
      if (like == null) {
        throw new NullPointerException("likes[" + i + "]");
      }
      final Component component = like.asComponent();
      if (filter == null || filter.test(component)) {
        if (components == null) {
          components = new ArrayList<>(size);
        }
        components.add(component);
      }
    }
    // if we filtered all elements out, just use an empty list instead
    if (components == null) return Collections.emptyList();
    // https://github.com/KyoriPowered/adventure/pull/327#discussion_r631420264
    // we pre-size the list, but filtering might make the actual size much smaller
    components.trimToSize();
    return Collections.unmodifiableList(components);
  }
Converts a list of {@link ComponentLike}s to a list of {@link Component}s.

<p>Only components that match {@code filter} will be returned.</p>

@param likes the component-likes
@param filter the component filter
@return the components
@since 4.8.0
api/src/main/java/net/kyori/adventure/text/ComponentLike.java