Replace stream with loop in RequestCondition's
This commit is contained in:
@@ -142,7 +142,13 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
|
||||
}
|
||||
|
||||
private long getValueMatchCount(Set<HeaderExpression> expressions) {
|
||||
return expressions.stream().filter(e -> e.getValue() != null && !e.isNegated()).count();
|
||||
long count = 0;
|
||||
for (HeaderExpression e : expressions) {
|
||||
if (e.getValue() != null && !e.isNegated()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -124,7 +124,13 @@ public final class ParamsRequestCondition extends AbstractRequestCondition<Param
|
||||
}
|
||||
|
||||
private long getValueMatchCount(Set<ParamExpression> expressions) {
|
||||
return expressions.stream().filter(e -> e.getValue() != null && !e.isNegated()).count();
|
||||
long count = 0;
|
||||
for (ParamExpression e : expressions) {
|
||||
if (e.getValue() != null && !e.isNegated()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.http.server.PathContainer;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -53,7 +52,7 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with the given {@code Stream} of URL patterns.
|
||||
* Creates a new instance with the given URL patterns.
|
||||
*/
|
||||
public PatternsRequestCondition(List<PathPattern> patterns) {
|
||||
this(new TreeSet<>(patterns));
|
||||
@@ -136,9 +135,13 @@ public final class PatternsRequestCondition extends AbstractRequestCondition<Pat
|
||||
*/
|
||||
private SortedSet<PathPattern> getMatchingPatterns(ServerWebExchange exchange) {
|
||||
PathContainer lookupPath = exchange.getRequest().getPath().pathWithinApplication();
|
||||
return this.patterns.stream()
|
||||
.filter(pattern -> pattern.matches(lookupPath))
|
||||
.collect(Collectors.toCollection(TreeSet::new));
|
||||
TreeSet<PathPattern> pathPatterns = new TreeSet<>();
|
||||
for (PathPattern pattern : this.patterns) {
|
||||
if (pattern.matches(lookupPath)) {
|
||||
pathPatterns.add(pattern);
|
||||
}
|
||||
}
|
||||
return pathPatterns;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -142,7 +142,13 @@ public final class HeadersRequestCondition extends AbstractRequestCondition<Head
|
||||
}
|
||||
|
||||
private long getValueMatchCount(Set<HeaderExpression> expressions) {
|
||||
return expressions.stream().filter(e -> e.getValue() != null && !e.isNegated()).count();
|
||||
long count = 0;
|
||||
for (HeaderExpression e : expressions) {
|
||||
if (e.getValue() != null && !e.isNegated()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -127,7 +127,13 @@ public final class ParamsRequestCondition extends AbstractRequestCondition<Param
|
||||
}
|
||||
|
||||
private long getValueMatchCount(Set<ParamExpression> expressions) {
|
||||
return expressions.stream().filter(e -> e.getValue() != null && !e.isNegated()).count();
|
||||
long count = 0;
|
||||
for (ParamExpression e : expressions) {
|
||||
if (e.getValue() != null && !e.isNegated()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user