Enum Class CoercionPolicy.Coercion

java.lang.Object
java.lang.Enum<CoercionPolicy.Coercion>
io.micronaut.serde.config.CoercionPolicy.Coercion
All Implemented Interfaces:
Serializable, Comparable<CoercionPolicy.Coercion>, Constable
Enclosing class:
CoercionPolicy

public static enum CoercionPolicy.Coercion extends Enum<CoercionPolicy.Coercion>
A single coercion a decoder may perform when the JSON shape does not match the requested type.
Since:
3.2
Author:
Denis Stepanov
  • Enum Constant Details

    • FLOAT_AS_INT

      public static final CoercionPolicy.Coercion FLOAT_AS_INT
      Read a floating point number into an integer type, truncating it. 42.5 becomes 42.
    • STRING_AS_NUMBER

      public static final CoercionPolicy.Coercion STRING_AS_NUMBER
      Read a string into a numeric type. "42" becomes 42.
    • BOOLEAN_AS_NUMBER

      public static final CoercionPolicy.Coercion BOOLEAN_AS_NUMBER
      Read a boolean into a numeric type. true becomes 1.
    • NUMBER_AS_BOOLEAN

      public static final CoercionPolicy.Coercion NUMBER_AS_BOOLEAN
      Read a number into a boolean. Any non-zero value becomes true.
    • STRING_AS_BOOLEAN

      public static final CoercionPolicy.Coercion STRING_AS_BOOLEAN
      Read a string into a boolean. "true" becomes true, anything else false.
    • SCALAR_AS_STRING

      public static final CoercionPolicy.Coercion SCALAR_AS_STRING
      Read a number or boolean into a string. 1234 becomes "1234".
    • UNWRAP_SINGLE_VALUE_ARRAY

      public static final CoercionPolicy.Coercion UNWRAP_SINGLE_VALUE_ARRAY
      Read a single element array into the scalar it contains. [42] becomes 42.
  • Method Details

    • values

      public static CoercionPolicy.Coercion[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CoercionPolicy.Coercion valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • message

      public String message()
      Returns:
      The message to report when this coercion is not allowed