This annotation is used by DataConverterUtils to determine the converter to use when converting an object to a target type. The DataConverters specified in value() will be used for converting an object.
As generic types can be annotated with this annotation, the annotation can specify a genericArgumentIndex() to specialize the associated location for this converter configuration.
Example:
@ConverterConfiguration(MyConverter.class)
@ConverterConfiguration(value = MyMapConverter.class, genericArgumentIndex = { 0 })
@ConverterConfiguration(value = MyIntConverter.class, genericArgumentIndex = { 0, 0 })
@ConverterConfiguration(value = MyStringConverter.class, genericArgumentIndex = { 0, 1})
public List<Map<Integer, String>> field;
In the above example, when an arbitrary value is being converted for the specified field, the following rules apply
(given that the default conversion mechanism is used):
MyConverterwill be used to convert the intial value to aList.MyMapConverterwill be used to convert the elements of the list to aMap.MyIntConverterwill be used to convert the keys of theMapto anInteger.MyStringConverterwill be used to convert the values of theMapto aString
For each type annotated with this annotation, the generic argument indices should be unique for each annotation. If multiple annotations are defined with the same generic argument locations, the implementation for conversion might throw an exception, or handle the collision in an implementation dependent manner. It is not required to warn about conflicting generic argument indices.
| public int[] | Specifies the generic argument location of the associated converter configuration. |
| public Class< | The data converters to use to convert the value at the location specified by genericArgumentIndex(). |
From: Annotation |
This array of indices specify the location on which the converter should be applied. If the array is empty, the
converter will be applied to the outermost type. If it has one element, it will be applied to the first generic
argument of the outermost type. If it has n elments, it will be applied to the nth outermost type,
with the index path specified by the array.
See the documentation of this class for example.
A list of converters can be specified, and they will be tried to execute the conversion in the specified order if the previous one fails.