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 typeT
.A value extractor for a generic type such as
Optional
,List
orMap
is tied to one specific type parameter ofT
. TheExtractedValue
annotation is used to mark that type parameter. A value extractor for a non-generic type such asOptionalInt
needs to declare the type of the wrapped element(s) usingExtractedValue.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
- Author:
- Gunnar Morling, Guillaume Smet
- See Also:
ExtractedValue
,UnwrapByDefault
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ValueExtractor.ValueReceiver
Provides a set of methods receiving value extracted by theValueExtractor
.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
extractValues(T originalValue, ValueExtractor.ValueReceiver receiver)
Extracts the values to validate from the original object.
-
-
-
Method Detail
-
extractValues
void extractValues(T originalValue, ValueExtractor.ValueReceiver receiver)
Extracts the values to validate from the original object.- Parameters:
originalValue
- the original value from which to extract the values, nevernull
receiver
- the correspondingValueReceiver
-
-