Class MissingRequiredPropertyException

All Implemented Interfaces:
Serializable

Thrown when parser input (or the source map of a Map-to-bean conversion) does not contain one or more properties marked @BeanProp(required=true).

The check runs once per bean, after all input properties have been read and before the bean is constructed, so records and constructor-argument beans get this exception instead of a constructor failure. An explicit null value counts as present.

This is a ParseException, so REST @Content parameters map it to 400 Bad Request.

Example:

public record Person(@BeanProp(required=true) String name, Integer age) {} try { JsonParser.DEFAULT.read("{\"age\":30}", Person.class); } catch (MissingRequiredPropertyException e) { e.getBeanClass(); // Person.class e.getPropertyNames(); // [name] }

See Also:
  • Constructor Details

    • MissingRequiredPropertyException

      public MissingRequiredPropertyException(ParserSession session, Class<?> beanClass, List<String> propertyNames)
      Constructor.
      Parameters:
      session - The parser session, or null. Used to add the input position to the message.
      beanClass - The bean class.
      propertyNames - The missing property names.
  • Method Details

    • check

      public static <T> BeanMap<T> check(ParserSession session, BeanMap<T> m)
      Throws this exception if the bean map is missing required properties.

      Parser sessions call this through ParserSession.checkRequired(BeanMap). Conversion code that has no parser session passes null, which omits the input position from the message.

      Type Parameters:
      T - The bean type.
      Parameters:
      session - The current parser session, or null if not parsing.
      m - The bean map to check. Can be null.
      Returns:
      The same bean map, for chaining.
      Throws:
      MissingRequiredPropertyException - If a required property was never written.
    • find

      Finds a MissingRequiredPropertyException in the cause chain of a throwable.

      Bean property setters wrap failures from nested conversions, so conversion code uses this to re-surface the original exception (which is a ParseException and maps to HTTP 400).

      Parameters:
      t - The throwable to inspect. Can be null.
      Returns:
      The first exception of this type in the chain (including t itself), or null if none.
    • getBeanClass

      public Class<?> getBeanClass()
      Returns the bean class whose required properties were missing.
      Returns:
      The bean class. Never null.
    • getPropertyNames

      Returns the names of the missing required properties, in bean property order.
      Returns:
      An unmodifiable list. Never null or empty.