Provide methods for obtaining include/exclude patterns in MappedInterceptor

Prior to this commit, MappedInterceptor had a getPathPatterns() method
that returned the include patterns.

This commit introduces getIncludePathPatterns() (which effectively
replaces getPathPatterns()) and getExcludePathPatterns(). In addition,
this commit deprecates getPathPatterns().

Closes gh-30971
This commit is contained in:
graceyu 2023-08-01 16:00:00 +08:00 committed by Sam Brannen
parent f00756bc7c
commit 6de95a2b37
1 changed files with 21 additions and 0 deletions

View File

@ -140,12 +140,33 @@ public final class MappedInterceptor implements HandlerInterceptor {
* Return the patterns this interceptor is mapped to.
*/
@Nullable
@Deprecated
public String[] getPathPatterns() {
return (!ObjectUtils.isEmpty(this.includePatterns) ?
Arrays.stream(this.includePatterns).map(PatternAdapter::getPatternString).toArray(String[]::new) :
null);
}
/**
* Return the include path patterns this interceptor is mapped to.
*/
@Nullable
public String[] getIncludePathPatterns() {
return (!ObjectUtils.isEmpty(this.includePatterns) ?
Arrays.stream(this.includePatterns).map(PatternAdapter::getPatternString).toArray(String[]::new) :
null);
}
/**
* Return the exclude path patterns this interceptor is mapped to.
*/
@Nullable
public String[] getExcludePathPatterns() {
return (!ObjectUtils.isEmpty(this.excludePatterns) ?
Arrays.stream(this.excludePatterns).map(PatternAdapter::getPatternString).toArray(String[]::new) :
null);
}
/**
* The target {@link HandlerInterceptor} to invoke in case of a match.
*/