Use lambda expressions for lazy instantiation (#1911)

Issue: SPR-17074
This commit is contained in:
Сергей Цыпанов
2018-07-31 14:03:18 +03:00
committed by Sam Brannen
parent 487e14d549
commit f8340838b3
11 changed files with 11 additions and 11 deletions

View File

@@ -94,7 +94,7 @@ public abstract class ExchangeFilterFunctions {
return ExchangeFilterFunction.ofRequestProcessor(request ->
credentialsFunction.apply(request)
.map(credentials -> Mono.just(insertAuthorizationHeader(request, credentials)))
.orElse(Mono.just(request)));
.orElseGet(() -> Mono.just(request)));
}
private static void checkIllegalCharacters(String username, String password) {

View File

@@ -139,7 +139,7 @@ class ModelInitializer {
.ofNullable(AnnotatedElementUtils.findMergedAnnotation(param.getAnnotatedElement(), ModelAttribute.class))
.filter(ann -> StringUtils.hasText(ann.value()))
.map(ModelAttribute::value)
.orElse(Conventions.getVariableNameForParameter(param));
.orElseGet(() -> Conventions.getVariableNameForParameter(param));
}
/** Find {@code @ModelAttribute} arguments also listed as {@code @SessionAttributes}. */

View File

@@ -244,7 +244,7 @@ public class RedirectView extends AbstractUrlBasedView {
while (found) {
String name = matcher.group(1);
Object value = (model.containsKey(name) ? model.get(name) : uriVariables.get(name));
Assert.notNull(value, "No value for URI variable '" + name + "'");
Assert.notNull(value, () -> "No value for URI variable '" + name + "'");
result.append(targetUrl.substring(endLastMatch, matcher.start()));
result.append(encodeUriVariable(value.toString()));
endLastMatch = matcher.end();

View File

@@ -286,7 +286,7 @@ public class ViewResolutionResultHandler extends HandlerResultHandlerSupport
return Optional.ofNullable(returnType.getMethodAnnotation(ModelAttribute.class))
.filter(ann -> StringUtils.hasText(ann.value()))
.map(ModelAttribute::value)
.orElse(Conventions.getVariableNameForParameter(returnType));
.orElseGet(() -> Conventions.getVariableNameForParameter(returnType));
}
private void updateBindingContext(BindingContext context, ServerWebExchange exchange) {