Class RequestBeanSetters
Methods for a concrete
(non-interface) @Request bean class.
RequestBeanArg resolves one of these once, when the @RestOp is registered (servlet init), instead of the historical per-request Class.getMethod lookup in
RestRequest.newRequestBean. A getter with no matching setter, or a bean with no public no-arg constructor,
now fails registration with an IllegalArgumentException naming the bean, the getter and the expected setter
— not only the requests that happen to supply that parameter.
Example:
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescription<T> TInstantiates the bean via its public no-arg constructor.static RequestBeanSettersresolve(Class<?> beanClass, RequestBeanMeta meta) Resolves the constructor and setters for a concrete@Requestbean class.voidInvokes the setter matching the specified getter on the specified bean.
-
Method Details
-
resolve
Resolves the constructor and setters for a concrete@Requestbean class.- Parameters:
beanClass- The bean class. Must not be an interface.meta- The metadata gathered from the class's annotated getters. Must not benull .- Returns:
- A new
RequestBeanSetters. - Throws:
IllegalArgumentException- IfbeanClasshas no public no-arg constructor, or if any annotated getter has no matching setter.
-
newInstance
Instantiates the bean via its public no-arg constructor.- Type Parameters:
T- The bean type.- Returns:
- A new, empty bean instance.
- Throws:
ReflectiveOperationException- If instantiation fails.
-
set
Invokes the setter matching the specified getter on the specified bean.- Parameters:
bean- The bean to populate. Must not benull .getter- The getter identifying the property, as returned byRequestBeanPropertyMeta.getGetter().value- The value to set. Callers skip absent (null ) values rather than passing them here.- Throws:
ReflectiveOperationException- If the setter invocation fails.
-