saker.build Documentation TaskDoc JavaDoc Packages
Repeatable annotation for fields and methods to specialize the conversion mechanism for a given location.

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):
  • MyConverter will be used to convert the intial value to a List.
  • MyMapConverter will be used to convert the elements of the list to a Map.
  • MyIntConverter will be used to convert the keys of the Map to an Integer.
  • MyStringConverter will be used to convert the values of the Map to a String

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.

Methods
public int[]
genericArgumentIndex() default {}
Specifies the generic argument location of the associated converter configuration.
public Class<extends DataConverter>[]
value() default {}
The data converters to use to convert the value at the location specified by genericArgumentIndex().
public abstract int[] genericArgumentIndex() default {}
Specifies the generic argument location of the associated converter configuration.

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.

The generic argument indices.
public abstract Class<extends DataConverter>[] value() default {}
The data converters to use to convert the value at the location specified by genericArgumentIndex().

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.

A list of converters.