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 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 ) );
}
}
}
ExtractedValue, UnwrapByDefault
| Modifier and Type | Class and Description |
|---|---|
| public static interface | ValueExtractor.ValueReceiver
Provides a set of methods receiving value extracted by the |
| Modifier and Type | Method and Description |
|---|---|
| public void | extractValues(T
the original value from which to extract the values, never
originalValue, ValueExtractor.nullthe corresponding receiverValueReceiverExtracts the values to validate from the original object. |
| extractValues | back to summary |
|---|---|
| public void extractValues(T originalValue, ValueExtractor. Extracts the values to validate from the original object.
| |
ValueExtractor.
The value has to be passed to the method corresponding best to the type of the original value.
| Modifier and Type | Method and Description |
|---|---|
| public void | indexedValue(String
the name of the node representing the container element. If not
nodeName, int null, the name will be used when adding a container element node to the
Paththe index of the value in the original object i, Object the value to validate object)Receives the value extracted from an indexed object (e.g. a |
| public void | iterableValue(String
the name of the node representing the container element. If not
nodeName, Object null, the name will be used when adding a container element node to the
Paththe value to validate object)Receives the value extracted from an iterable object that is not indexed (e.g.
a |
| public void | keyedValue(String
the name of the node representing the container element. If not
nodeName, Object null, the name will be used when adding a container element node to the
Paththe key of the value in the original object key, Object the value to validate object)Receives the value extracted from a keyed object (e.g. a |
| public void |
| indexedValue | back to summary |
|---|---|
| public void indexedValue(String nodeName, int i, Object object) Receives the value extracted from an indexed object (e.g. a | |
| iterableValue | back to summary |
|---|---|
| public void iterableValue(String nodeName, Object object) Receives the value extracted from an iterable object that is not indexed (e.g.
a | |
| keyedValue | back to summary |
|---|---|
| public void keyedValue(String nodeName, Object key, Object object) Receives the value extracted from a keyed object (e.g. a | |
| value | back to summary |
|---|---|
| public void value(String nodeName, Object object) Receives the value extracted from an object. | |