Skip to content

Commit bc8bfc8

Browse files
committed
Polish JavaDoc
Issue gh-14597
1 parent 1a515a3 commit bc8bfc8

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

core/src/main/java/org/springframework/security/authorization/method/AuthorizationAdvisorProxyFactory.java

+33-1
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,30 @@ public void setAdvisors(Collection<AuthorizationAdvisor> advisors) {
195195
*
196196
* <pre>
197197
* AuthorizationAdvisorProxyFactory proxyFactory = new AuthorizationAdvisorProxyFactory();
198-
* proxyFactory.setTargetVisitor(AuthorizationAdvisorProxyFactory.DEFAULT_VISITOR_IGNORE_VALUE_TYPES);
198+
* proxyFactory.setTargetVisitor(TargetVisitor.defaultsSkipValueTypes());
199+
* </pre>
200+
*
201+
* <p>
202+
* The default {@link TargetVisitor} proxies {@link Class} instances as well as
203+
* instances contained in reactive types (if reactor is present), collection types,
204+
* and other container types like {@link Optional} and {@link Supplier}.
205+
*
206+
* <p>
207+
* If you want to add support for another container type, you can do so in the
208+
* following way:
209+
*
210+
* <pre>
211+
* TargetVisitor functions = (factory, target) -> {
212+
* if (target instanceof Function function) {
213+
* return (input) -> factory.proxy(function.apply(input));
214+
* }
215+
* return null;
216+
* };
217+
* AuthorizationAdvisorProxyFactory proxyFactory = new AuthorizationAdvisorProxyFactory();
218+
* proxyFactory.setTargetVisitor(TargetVisitor.of(functions, TargetVisitor.defaultsSkipValueTypes()));
199219
* </pre>
200220
* @param visitor the visitor to use to introduce specialized behavior for a type
221+
* @see TargetVisitor#defaults
201222
*/
202223
public void setTargetVisitor(TargetVisitor visitor) {
203224
Assert.notNull(visitor, "delegate cannot be null");
@@ -260,6 +281,17 @@ static TargetVisitor defaultsSkipValueTypes() {
260281
return AuthorizationAdvisorProxyFactory.DEFAULT_VISITOR_SKIP_VALUE_TYPES;
261282
}
262283

284+
/**
285+
* Compose a set of visitors. This is helpful when you are customizing for a given
286+
* type and still want the defaults applied for the remaining types.
287+
*
288+
* <p>
289+
* The resulting visitor will execute the first visitor that returns a non-null
290+
* value.
291+
* @param visitors the set of visitors
292+
* @return a composite that executes the first visitor that returns a non-null
293+
* value
294+
*/
263295
static TargetVisitor of(TargetVisitor... visitors) {
264296
return (proxyFactory, target) -> {
265297
for (TargetVisitor visitor : visitors) {

0 commit comments

Comments
 (0)