Annotation Type CsvNumber


  • @Documented
    @Retention(RUNTIME)
    @Target(FIELD)
    @Repeatable(CsvNumbers.class)
    public @interface CsvNumber
    This annotation indicates that the destination field is a number that is specially formatted. Numbers that have no more formatting than that which comes with a locale (or the default locale) do not require this annotation. If a locale is specified in the attendant CSV binding annotation (CsvBindByName, CsvBindByPosition, etc.), it is used for the conversion. The following types are supported:
    • byte / Byte
    • double / Double
    • float / Float
    • int / Integer
    • long / Long
    • short / Short
    • BigDecimal
    • BigInteger
    Since:
    4.2
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      java.lang.String value
      A decimal format string.
    • 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.
      java.lang.String writeFormat
      A number format string.
      boolean writeFormatEqualsReadFormat
      Whether or not the same format string is used for writing as for reading.
    • Element Detail

      • value

        java.lang.String value
        A decimal format string. This must be a localized pattern understood by DecimalFormat. The locale is gleaned from one of the other CSV-related annotations if present there, or failing that, is the default locale for the JVM. If your code might run under different locales, you are strongly encouraged to always specify a locale for conversions, otherwise your code will behave unpredictably.
        Returns:
        The format string for parsing input
      • writeFormatEqualsReadFormat

        boolean writeFormatEqualsReadFormat
        Whether or not the same format string is used for writing as for reading. If this is true, value() is used for both reading and writing and writeFormat() is ignored.
        Returns:
        Whether the read format is used for writing as well
        Since:
        5.0
        Default:
        true
      • writeFormat

        java.lang.String writeFormat
        A number format string. The default value is blank and only exists to make sure the parameter is optional.
        Returns:
        The format string for formatting output
        Since:
        5.0
        See Also:
        value(), writeFormatEqualsReadFormat()
        Default:
        ""
      • 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:
        {""}