Annotation Interface ApiMapper
Specifies the MapStruct (or any bean) mapper class and optional method name
to use for converting query results before returning them from a dynamic
ApiFindController method.
When the interceptor has retrieved the list of entities from the
JpaService, it looks for this annotation to
determine whether to apply a transformation. If method() is blank,
the framework uses the first compatible single-argument method found on the
mapper class.
Example
@ApiFindController
public interface ProductController {
@GetMapping("/products")
@ApiFind(entity = Product.class, id = Long.class)
@ApiMapper(value = ProductMapper.class, method = "toDto")
List<ProductDto> search(@RequestBody ProductFilter filter);
}
- Author:
- Francesco Baldi
- See Also:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional Elements
-
Element Details
-
value
Class<?> valueThe mapper class whose method will be called on each result entity. The class must be a Spring-managed bean (e.g., a MapStruct mapper annotated with@Mapper(componentModel = "spring")).- Returns:
- the mapper class; must not be
null
-
method
String methodThe name of the mapping method to invoke on the mapper. If left blank (default), the framework resolves the method automatically by matching the entity type to the method's parameter type.- Returns:
- the mapping method name, or
""for auto-resolution
- Default:
""
-