Class GeneratedSerdeExceptionUtil
java.lang.Object
io.micronaut.serde.util.GeneratedSerdeExceptionUtil
Exception helpers used by generated serdes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumResult of a generated deserializer property dispatch. -
Method Summary
Modifier and TypeMethodDescriptionstatic SerdeExceptionduplicateProperty(io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument) Creates aSerdeExceptionfor a duplicate property and enriches it with the property path.static booleanWhether primitive values should reject explicit null input.static <E extends Enum<E>>
@Nullable EhandleUnknownEnumValue(Deserializer.DecoderContext context, io.micronaut.core.type.Argument<E> enumType, String value) Handles an unknown enum value according to deserialization configuration.static booleanignoreUnknown(Deserializer.DecoderContext context) Whether unknown properties should be skipped.static SerdeExceptionnullValue(io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument) Creates an exception for a null value assigned to a property that cannot accept null.static booleanWhether constructor arguments should reject missing or explicit null values.static SerdeExceptionstrictNullableConstructorParameter(io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument) Creates an exception for a constructor parameter rejected by strict nullable deserialization.static SerdeExceptionunknownEnumValue(io.micronaut.core.type.Argument<?> enumType, String value) Creates aSerdeExceptionfor an unknown enum value.static SerdeExceptionunknownProperty(io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument) Creates aSerdeExceptionfor an unknown property and enriches it with the property path.static SerdeExceptionwithPropertyPath(Throwable exception, io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument) Converts anyThrowableinto aSerdeExceptionand appends a property path segment.
-
Method Details
-
unknownProperty
public static SerdeException unknownProperty(io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument) Creates aSerdeExceptionfor an unknown property and enriches it with the property path.- Parameters:
beanType- The declaring bean argument.propertyArgument- The property argument.- Returns:
- The configured exception.
-
duplicateProperty
public static SerdeException duplicateProperty(io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument) Creates aSerdeExceptionfor a duplicate property and enriches it with the property path.- Parameters:
beanType- The declaring bean argument.propertyArgument- The property argument.- Returns:
- The configured exception.
-
unknownEnumValue
public static SerdeException unknownEnumValue(io.micronaut.core.type.Argument<?> enumType, String value) Creates aSerdeExceptionfor an unknown enum value.- Parameters:
enumType- The enum argument being deserialized.value- The incoming value that could not be resolved.- Returns:
- The configured exception.
-
handleUnknownEnumValue
public static <E extends Enum<E>> @Nullable E handleUnknownEnumValue(Deserializer.DecoderContext context, io.micronaut.core.type.Argument<E> enumType, String value) throws SerdeException Handles an unknown enum value according to deserialization configuration.- Type Parameters:
E- The enum type.- Parameters:
context- The decoder context.enumType- The enum argument being deserialized.value- The incoming value that could not be resolved.- Returns:
nullwhen unknown enum values are configured to deserialize as null.- Throws:
SerdeException- If the value should fail deserialization.- Since:
- 3.0
-
nullValue
public static SerdeException nullValue(io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument) Creates an exception for a null value assigned to a property that cannot accept null.- Parameters:
beanType- The declaring bean argument.propertyArgument- The property argument.- Returns:
- The configured exception.
- Since:
- 3.0
-
failOnNullForPrimitives
Whether primitive values should reject explicit null input.- Parameters:
context- The decoder context.- Returns:
trueif explicit null primitive values should fail deserialization- Since:
- 3.0
-
ignoreUnknown
Whether unknown properties should be skipped.- Parameters:
context- The decoder context.- Returns:
trueif unknown properties should be ignored- Since:
- 3.0
-
strictNullable
Whether constructor arguments should reject missing or explicit null values.- Parameters:
context- The decoder context.- Returns:
trueif strict nullable deserialization is enabled- Since:
- 3.0
-
strictNullableConstructorParameter
public static SerdeException strictNullableConstructorParameter(io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument) Creates an exception for a constructor parameter rejected by strict nullable deserialization.- Parameters:
beanType- The declaring bean argument.propertyArgument- The property argument.- Returns:
- The configured exception.
- Since:
- 3.0
-
withPropertyPath
public static SerdeException withPropertyPath(Throwable exception, io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument) Converts anyThrowableinto aSerdeExceptionand appends a property path segment.- Parameters:
exception- The original exception.beanType- The declaring bean argument.propertyArgument- The property argument.- Returns:
- A serde exception enriched with property path information.
-