View Javadoc
1   package org.csveed.annotations;
2   
3   import java.lang.annotation.ElementType;
4   import java.lang.annotation.Retention;
5   import java.lang.annotation.RetentionPolicy;
6   import java.lang.annotation.Target;
7   
8   /**
9   * Various settings for a BeanInstructionsImpl translating to a CSV cell. By default every field in a BeanInstructionsImpl is expected to be
10  * a CsvCell, even if not so marked. Use @CsvIgnore to prevent a BeanInstructionsImpl field from being taken into account for
11  * both serialization and deserialization.
12  * @author Robert Bor
13  */
14  @Target(ElementType.FIELD)
15  @Retention(RetentionPolicy.RUNTIME)
16  public @interface CsvCell {
17  
18      /**
19      * This value will only be used if CsvFile.useHeaders == false. If this value is not set, the index will be
20      * automatically determined on the basis of the order of the fields within the class. If this value is set,
21      * the column at the index position will be used for mapping to this field. A 1-based approach is used because
22      * the error report is aimed at the Excel user, not the developer.
23      * @return the index column to use for the mapping
24      */
25      int columnIndex() default -1;
26  
27      /**
28      * By default the column name is inferred from the property name. However, if CsvFile.useHeaders == false, or the
29      * naming is not what you want in the BeanInstructions, you can override the column name to map to using this value.
30      * @return the column name in the CSV file header to use for mapping
31      */
32      String columnName() default "";
33  
34      /**
35      * If required is set, the parse process will generate an error if the value is null after deserialization
36      * @return whether the field must be not null
37      */
38      boolean required() default false;
39  
40  }