class RecordFieldExtractor<T> implements FieldExtractor<T> {

	private List<String> names;

	private final Class<? extends T> targetType;

	private final RecordComponent[] recordComponents;

	public RecordFieldExtractor(Class<? extends T> targetType) {
		Assert.notNull(targetType, "target type must not be null");
		Assert.isTrue(targetType.isRecord(), "target type must be a record");
		this.targetType = targetType;
		this.recordComponents = this.targetType.getRecordComponents();
		this.names = getRecordComponentNames();
	}

	/**
	 * Set the names of record components to extract.
	 * @param names of record component to be extracted.
	 */
	public void setNames(String... names) {
		Assert.notNull(names, "Names must not be null");
		Assert.notEmpty(names, "Names must not be empty");
		validate(names);
		this.names = Arrays.stream(names).toList();
	}

	/**
	 * @see FieldExtractor#extract(Object)
	 */
	@Override
	public Object[] extract(T item) {<FILL_FUNCTION_BODY>}

	private List<String> getRecordComponentNames() {
		return Arrays.stream(this.recordComponents).map(RecordComponent::getName).toList();
	}

	private void validate(String[] names) {
		for (String name : names) {
			if (getRecordComponentByName(name) == null) {
				throw new IllegalArgumentException(
						"Component '" + name + "' is not defined in record " + targetType.getName());
			}
		}
	}

	@Nullable
	private RecordComponent getRecordComponentByName(String name) {
		return Arrays.stream(this.recordComponents)
			.filter(recordComponent -> recordComponent.getName().equals(name))
			.findFirst()
			.orElse(null);
	}

}

		List<Object> values = new ArrayList<>();
		for (String componentName : this.names) {
			RecordComponent recordComponent = getRecordComponentByName(componentName);
			Object value;
			try {
				value = recordComponent.getAccessor().invoke(item);
				values.add(value);
			}
			catch (IllegalAccessException | InvocationTargetException e) {
				throw new RuntimeException("Unable to extract value for record component " + componentName, e);
			}
		}
		return values.toArray();
	
<no_super_class>