Class ProblemMapperList
ProblemMappers with a single bean-store entry.
The problem-details processor resolves only the unnamed ProblemMapper from the bean store, so a
second @Bean public ProblemMapper foo() factory method (even a differently named one) would register a
distinct bean that the processor never consults. To register more than one mapper, declare a single
@Bean public ProblemMapperList mappers() factory and let the list carry the dispatch order:
For the single-mapper case the conventional pattern still works —
@Bean public ProblemMapper<MyException> mapper() registers under ProblemMapper.class
and the server-side processor picks it up via BeanStore.getBean(ProblemMapper.class) without
needing a list wrapper.
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(Collection<? extends ProblemMapper<?>> values) Appends a collection of mappers to the end of the list, in iteration order.append(ProblemMapper<?> mapper) Appends a mapper to the end of the list.List<ProblemMapper<?>>asList()Returns the registered mappers in their declared order.booleanisEmpty()Returnstruewhen this list contains no mappers.static ProblemMapperListof(ProblemMapper<?>... mappers) Creates a list populated with the supplied mappers in argument order.
-
Constructor Details
-
ProblemMapperList
public ProblemMapperList()Creates an empty list. Mappers can be added viaappend(ProblemMapper)/append(Collection).
-
-
Method Details
-
of
Creates a list populated with the supplied mappers in argument order.- Parameters:
mappers- The mappers to add. Can benull , andnull entries are skipped; duplicates are allowed and preserved.- Returns:
- A new
ProblemMapperListcontaining the supplied mappers.
-
append
Appends a mapper to the end of the list.- Parameters:
mapper- The mapper to add. Can benull (no-op).- Returns:
- This object for fluent chaining.
-
append
Appends a collection of mappers to the end of the list, in iteration order.- Parameters:
values- The mappers to add. Can benull , andnull entries are skipped.- Returns:
- This object for fluent chaining.
-
asList
Returns the registered mappers in their declared order.- Returns:
- An unmodifiable view of the underlying list. Never
null.
-
isEmpty
Returnstruewhen this list contains no mappers.- Returns:
truewhenasList()is empty.
-