Enum Class CoercionPolicy.Coercion
- All Implemented Interfaces:
Serializable, Comparable<CoercionPolicy.Coercion>, Constable
- Enclosing class:
CoercionPolicy
A single coercion a decoder may perform when the JSON shape does not match the requested
type.
- Since:
- 3.2
- Author:
- Denis Stepanov
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionRead a boolean into a numeric type.Read a floating point number into an integer type, truncating it.Read a number into a boolean.Read a number or boolean into a string.Read a string into a boolean.Read a string into a numeric type.Read a single element array into the scalar it contains. -
Method Summary
Modifier and TypeMethodDescriptionmessage()static CoercionPolicy.CoercionReturns the enum constant of this class with the specified name.static CoercionPolicy.Coercion[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
FLOAT_AS_INT
Read a floating point number into an integer type, truncating it.42.5becomes42. -
STRING_AS_NUMBER
Read a string into a numeric type."42"becomes42. -
BOOLEAN_AS_NUMBER
Read a boolean into a numeric type.truebecomes1. -
NUMBER_AS_BOOLEAN
Read a number into a boolean. Any non-zero value becomestrue. -
STRING_AS_BOOLEAN
Read a string into a boolean."true"becomestrue, anything elsefalse. -
SCALAR_AS_STRING
Read a number or boolean into a string.1234becomes"1234". -
UNWRAP_SINGLE_VALUE_ARRAY
Read a single element array into the scalar it contains.[42]becomes42.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
message
- Returns:
- The message to report when this coercion is not allowed
-