Annotation Type CsvCustomBindByPosition
-
@Documented @Retention(RUNTIME) @Target(FIELD) @Repeatable(CsvCustomBindByPositions.class) public @interface CsvCustomBindByPosition
Allows us to specify a class that will perform the translation from source to destination. For special needs, we can implement a class that takes the source field from the CSV and translates it into a form of our choice.- Since:
- 3.8
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.Class<? extends AbstractBeanField>
converter
The class that takes care of the conversion.int
position
The column position in the input that is used to fill the annotated field.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.String[]
profiles
A profile can be used to annotate the same field differently for different inputs or outputs.boolean
required
Whether or not the annotated field is required to be present in every data set of the input.
-
-
-
Element Detail
-
converter
java.lang.Class<? extends AbstractBeanField> converter
The class that takes care of the conversion. Every custom converter must be descended fromAbstractBeanField
and override the methodAbstractBeanField.convert(java.lang.String)
.- Returns:
- The implementation that can convert to the type of this field.
-
-
-
required
boolean required
Whether or not the annotated field is required to be present in every data set of the input. This means that the input cannot be empty. The output after conversion is not guaranteed to be non-empty. "Input" means the string from the field in the CSV file on reading and the bean member variable on writing.- Returns:
- If the field is required to contain information.
- Since:
- 3.10
- Default:
- false
-
-
-
profiles
java.lang.String[] profiles
A profile can be used to annotate the same field differently for different inputs or outputs.Perhaps you have multiple input sources, and they all use different header names or positions for the same data. With profiles, you don't have to create different beans with the same fields and different annotations for each input. Simply annotate the same field multiple times and specify the profile when you parse the input.
The same applies to output: if you want to be able to represent the same data in multiple CSV formats (that is, with different headers or orders), annotate the bean fields multiple times with different profiles and specify which profile you want to use on writing.
Results are undefined if profile names are not unique.
If the same configuration applies to multiple profiles, simply list all applicable profile names here. This parameter is an array of strings.
The empty string, which is the default value, specifies the default profile and will be used if no annotation for the specific profile being used can be found, or if no profile is specified.
- Returns:
- The names of the profiles this configuration is for
- Since:
- 5.4
- Default:
- {""}
-
-