i want to write an value extractor to support validation scala list item by jakarta validation
the value extractor is defined as
public interface ValueExtractor<T> {
/**
* Extracts the values to validate from the original object.
*
* @param originalValue the original value from which to extract the values, never
* {@code null}
* @param receiver the corresponding {@code ValueReceiver}
*/
void extractValues(T originalValue, ValueReceiver receiver);
/**
* Provides a set of methods receiving value extracted by the {@link ValueExtractor}.
* <p>
* The value has to be passed to the method corresponding best to the type of the
* original value.
*
* @since 2.0
*/
interface ValueReceiver {
/**
* Receives the value extracted from an object.
*
* @param nodeName the name of the node representing the container element. If not
* {@code null}, the name will be used when adding a container element node to the
* {@link Path}
* @param object the value to validate
*/
void value(String nodeName, Object object);
/**
* Receives the value extracted from an iterable object that is not indexed (e.g.
* a {@link Iterable}, {@link Set} or a {@link Map}).
*
* @param nodeName the name of the node representing the container element. If not
* {@code null}, the name will be used when adding a container element node to the
* {@link Path}
* @param object the value to validate
*/
void iterableValue(String nodeName, Object object);
/**
* Receives the value extracted from an indexed object (e.g. a {@link List}).
*
* @param nodeName the name of the node representing the container element. If not
* {@code null}, the name will be used when adding a container element node to the
* {@link Path}
* @param i the index of the value in the original object
* @param object the value to validate
*/
void indexedValue(String nodeName, int i, Object object);
/**
* Receives the value extracted from a keyed object (e.g. a {@link Map}).
*
* @param nodeName the name of the node representing the container element. If not
* {@code null}, the name will be used when adding a container element node to the
* {@link Path}
* @param key the key of the value in the original object
* @param object the value to validate
*/
void keyedValue(String nodeName, Object key, Object object);
}
}
/**
* Marks the type parameter of a generic container type to which a {@link ValueExtractor} is
* tied or specifies the type of the wrapped element(s) of non-generic container types.
* <p>
* Must be given exactly once for a value extractor type.
*
* @author Gunnar Morling
* @author Guillaume Smet
*
* @see ValueExtractor
* @since 2.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@Documented
public @interface ExtractedValue {
/**
* The type of the value extracted by the {@link ValueExtractor}. If not set, the type
* will be automatically inferred from the type argument of the parameterized type.
* <p>
* Used to define value extractors for non-generic wrapper types e.g.
* {@link OptionalInt}.
* <p>
* May not be used when {@code ExtractedValue} is defined on the type parameter of
* a generic container type. A {@code ValueExtractorDefinitionException} will be thrown
* in this case.
*
* @return the type of the value extracted by the value extractor
*/
Class<?> type() default void.class;
}
and the java list value extractor is
how can i do the same thing with scala, my scala is 2.13, i have try to upgrade to scala 3.3.1 but it was broken by thousand of errors and some part can’t upgrade to scala 3