@Normalized annotation

back to index

Action

Marks a property as "normalized", performing different value normalization operations before making an assignment.

Javadoc Ref :  Javadoc reference@Normalized

 Input Types 1
String
 Output Types
String
   

1Automatic conversion will take place if the provided input does not match any of the input classes, as described in the conversions part of the manual.

Arguments

 transform

Specifies the type of transformation to use before assigning the value. Can be any of:

  • TransformType.UPPERCASE
  • TransformType.LOWERCASE
  • TransformType.CAPITALIZE
  • TransformType.NONE  (default value)
 trim

Specifies how to process leading and trailing spaces of the value. Can be any of:

  • TrimType.NONE
  • TrimType.LEADING
  • TrimType.TRAILING
  • TrimType.BOTH
whitespace

Specifies how to process whitespaces present in the value. Can be any of:

  • WhitespaceProcess.ing.COLLAPSE
  • WhitespaceProcessing.PRESERVE
  • WhitespaceProcessing.REPLACE
pad

Specifies how to pad the value. Default is no padding. Can be any of:

  • PadType.LEFT
  • PadType.RIGHT
  • PadType.NONE
padChar
Specifies which character to use when padding the value. Default is '0'
padLength
Specifies the length of the field into which to apply the padding. Default is 0
convertNull

If set to true, allows nulls to be converted into a base value before assignment or before feeding the result to the next step. The resulting value depends on what type expects the next step:

  • CharSequences (String,StringBuffer,StringBuilder) nulls are converted to ""
  • Primitive numeric data type nulls are converted to 0.
  • Boolean data type nulls are converted to false
  • Character nulls are converted to the NUL character ('\u0000')
  • Otherwise, the null is left untransformed
defaultValue
If set to something different than the default (the empty string), specifies a default value that is used whenever a null value is received. The resulting value depends on what type expects the next step.
search
Array of regular expressions to be located within the data for replacement. Earch array member is searched for within the data, and if found it is replaced by the corresponding (by index position) string of the replace attribute
(Available since v1.1)
replace
Array of regular expressions to be used for replacement when the corresponding (by position) search expression is found
(Available since v1.1)

 

Example

@Normalized(
  pad=PadType.RIGHT,
  padChar='0',
  padLength=10,
  search={"-|."},
  replace={""},
)
private String someField;