Interface ValueExtractor<T>
- Type Parameters:
T- the container type handled by a specific implementation
public interface ValueExtractor<T>
Defines the logic used to extract the values from a container object of type
T.
A value extractor for a generic type such as Optional, List or Map
is tied to one specific type parameter of T. The ExtractedValue annotation
is used to mark that type parameter. A value extractor for a non-generic type such as
OptionalInt needs to declare the type of the wrapped element(s) using
ExtractedValue.type().
The extracted values are passed to the corresponding method of the ValueExtractor.ValueReceiver.
A typical value extractor implementation for List may look like this:
public class ListValueExtractor implements
ValueExtractor<List<@ExtractedValue ?>> {
@Override
public void extractValues(List<?> originalValue, ValueReceiver receiver) {
for ( int i = 0; i < originalValue.size(); i++ ) {
receiver.indexedValue( "<list element>", i, originalValue.get( i ) );
}
}
}
- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceProvides a set of methods receiving value extracted by theValueExtractor. -
Method Summary
Modifier and TypeMethodDescriptionvoidextractValues(T originalValue, ValueExtractor.ValueReceiver receiver) Extracts the values to validate from the original object.
-
Method Details
-
extractValues
Extracts the values to validate from the original object.- Parameters:
originalValue- the original value from which to extract the values, nevernullreceiver- the correspondingValueReceiver
-