@SuppressWarnings({"unchecked", "rawtypes"})
  public static <O extends DataComponentValue> @NotNull O convert(final @NotNull Class<O> target, final @NotNull Key key, final @NotNull DataComponentValue in) {
    if (target.isInstance(in)) {
      return target.cast(in);
    }

    final @Nullable RegisteredConversion converter = ConversionCache.converter(in.getClass(), target);
    if (converter == null) {
      throw new IllegalArgumentException("There is no data holder converter registered to convert from a " + in.getClass() + " instance to a " + target + " (on field " + key + ")");
    }

    try {
      return (O) ((Conversion) converter.conversion).convert(key, in);
    } catch (final Exception ex) {
      throw new IllegalStateException("Failed to convert data component value of type " + in.getClass() + " to type " + target + " due to an error in a converter provided by " + converter.provider.asString() + "!", ex);
    }
  }
Try to convert the data component value {@code in} to the provided output type.

@param target the target type
@param key the key this value is for
@param in the input value
@param <O> the output type
@return a value of target type
@since 4.17.0
api/src/main/java/net/kyori/adventure/text/event/DataComponentValueConverterRegistry.java