mirror of
https://github.com/spring-projects/spring-security.git
synced 2026-03-30 14:08:11 +00:00
Improve And/Or-RequestMatcher/ServerWebExchangeMatcher API
Currently, the List-receiving constructors of AndRequestMatcher, OrRequestMatcher, AndServerWebExchangeMatcher, and OrServerWebExchangeMatcher don't support covariance, which adds obstacles to users of these APIs. For example, one cannot pass a List<PathPatternRequestMatcher> to OrRequestMatcher(List<RequestMatcher>). This commit resolves the aforementioned problem. It should not break existing code. Signed-off-by: Ziqin Wang <ziqin@wangziqin.net>
This commit is contained in:
parent
46e27aa693
commit
acbf64a47d
@ -42,9 +42,9 @@ public class AndServerWebExchangeMatcher implements ServerWebExchangeMatcher {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(AndServerWebExchangeMatcher.class);
|
||||
|
||||
private final List<ServerWebExchangeMatcher> matchers;
|
||||
private final List<? extends ServerWebExchangeMatcher> matchers;
|
||||
|
||||
public AndServerWebExchangeMatcher(List<ServerWebExchangeMatcher> matchers) {
|
||||
public AndServerWebExchangeMatcher(List<? extends ServerWebExchangeMatcher> matchers) {
|
||||
Assert.notEmpty(matchers, "matchers cannot be empty");
|
||||
this.matchers = matchers;
|
||||
}
|
||||
|
||||
@ -40,9 +40,9 @@ public class OrServerWebExchangeMatcher implements ServerWebExchangeMatcher {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(OrServerWebExchangeMatcher.class);
|
||||
|
||||
private final List<ServerWebExchangeMatcher> matchers;
|
||||
private final List<? extends ServerWebExchangeMatcher> matchers;
|
||||
|
||||
public OrServerWebExchangeMatcher(List<ServerWebExchangeMatcher> matchers) {
|
||||
public OrServerWebExchangeMatcher(List<? extends ServerWebExchangeMatcher> matchers) {
|
||||
Assert.notEmpty(matchers, "matchers cannot be empty");
|
||||
this.matchers = matchers;
|
||||
}
|
||||
|
||||
@ -36,13 +36,13 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public final class AndRequestMatcher implements RequestMatcher {
|
||||
|
||||
private final List<RequestMatcher> requestMatchers;
|
||||
private final List<? extends RequestMatcher> requestMatchers;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
* @param requestMatchers the {@link RequestMatcher} instances to try
|
||||
*/
|
||||
public AndRequestMatcher(List<RequestMatcher> requestMatchers) {
|
||||
public AndRequestMatcher(List<? extends RequestMatcher> requestMatchers) {
|
||||
Assert.notEmpty(requestMatchers, "requestMatchers must contain a value");
|
||||
Assert.noNullElements(requestMatchers, "requestMatchers cannot contain null values");
|
||||
this.requestMatchers = requestMatchers;
|
||||
|
||||
@ -34,13 +34,13 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public final class OrRequestMatcher implements RequestMatcher {
|
||||
|
||||
private final List<RequestMatcher> requestMatchers;
|
||||
private final List<? extends RequestMatcher> requestMatchers;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
* @param requestMatchers the {@link RequestMatcher} instances to try
|
||||
*/
|
||||
public OrRequestMatcher(List<RequestMatcher> requestMatchers) {
|
||||
public OrRequestMatcher(List<? extends RequestMatcher> requestMatchers) {
|
||||
Assert.notEmpty(requestMatchers, "requestMatchers must contain a value");
|
||||
Assert.noNullElements(requestMatchers, "requestMatchers cannot contain null values");
|
||||
this.requestMatchers = requestMatchers;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user