T
- the container type handled by a specific implementationpublic interface ValueExtractor<T>
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 ) ); } } }
ExtractedValue
,
UnwrapByDefault
Modifier and Type | Interface and Description |
---|---|
static interface |
ValueExtractor.ValueReceiver
Provides a set of methods receiving value extracted by the
ValueExtractor . |
Modifier and Type | Method and Description |
---|---|
void |
extractValues(T originalValue,
ValueExtractor.ValueReceiver receiver)
Extracts the values to validate from the original object.
|
void extractValues(T originalValue, ValueExtractor.ValueReceiver receiver)
originalValue
- the original value from which to extract the values, never
null
receiver
- the corresponding ValueReceiver
Copyright © 2021 JBoss by Red Hat. All rights reserved.