Class MissingRequiredPropertyException
- All Implemented Interfaces:
Serializable
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
This is a ParseException, so REST @Content parameters map it to
Example:
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMissingRequiredPropertyException(ParserSession session, Class<?> beanClass, List<String> propertyNames) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> BeanMap<T>check(ParserSession session, BeanMap<T> m) Throws this exception if the bean map is missing required properties.Finds aMissingRequiredPropertyExceptionin the cause chain of a throwable.Class<?>Returns the bean class whose required properties were missing.Returns the names of the missing required properties, in bean property order.Methods inherited from class org.apache.juneau.marshall.parser.ParseException
create, getRootCause, setMessageMethods inherited from class org.apache.juneau.commons.BasicRuntimeException
getMessageMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
MissingRequiredPropertyException
public MissingRequiredPropertyException(ParserSession session, Class<?> beanClass, List<String> propertyNames) Constructor.- Parameters:
session- The parser session, ornull . Used to add the input position to the message.beanClass- The bean class.propertyNames- The missing property names.
-
-
Method Details
-
check
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 passesnull , which omits the input position from the message.- Type Parameters:
T- The bean type.- Parameters:
session- The current parser session, ornull if not parsing.m- The bean map to check. Can benull .- Returns:
- The same bean map, for chaining.
- Throws:
MissingRequiredPropertyException- If a required property was never written.
-
find
Finds aMissingRequiredPropertyExceptionin 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
ParseExceptionand maps to HTTP 400).- Parameters:
t- The throwable to inspect. Can benull .- Returns:
- The first exception of this type in the chain (including
t itself), ornull if none.
-
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.
-