Class GeneratedSerdeExceptionUtil

java.lang.Object
io.micronaut.serde.util.GeneratedSerdeExceptionUtil

@Internal public final class GeneratedSerdeExceptionUtil extends Object
Exception helpers used by generated serdes.
  • Method Details

    • unknownProperty

      public static SerdeException unknownProperty(io.micronaut.core.type.Argument<?> beanType, io.micronaut.core.type.Argument<?> propertyArgument)
      Creates a SerdeException for 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 a SerdeException for 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 a SerdeException for 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:
      null when 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

      public static boolean failOnNullForPrimitives(Deserializer.DecoderContext context)
      Whether primitive values should reject explicit null input.
      Parameters:
      context - The decoder context.
      Returns:
      true if explicit null primitive values should fail deserialization
      Since:
      3.0
    • ignoreUnknown

      public static boolean ignoreUnknown(Deserializer.DecoderContext context)
      Whether unknown properties should be skipped.
      Parameters:
      context - The decoder context.
      Returns:
      true if unknown properties should be ignored
      Since:
      3.0
    • strictNullable

      public static boolean strictNullable(Deserializer.DecoderContext context)
      Whether constructor arguments should reject missing or explicit null values.
      Parameters:
      context - The decoder context.
      Returns:
      true if 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 any Throwable into a SerdeException and 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.