Merge pull request #24477 from izeye

* pr/24477:
  Use BindResult.orElseGet() where beneficial

Closes gh-24477
This commit is contained in:
Stephane Nicoll
2020-12-15 11:29:51 +01:00
2 changed files with 3 additions and 2 deletions

View File

@@ -58,7 +58,8 @@ abstract class AbstractSessionCondition extends SpringBootCondition {
return binder.bind("spring.session.store-type", StoreType.class)
.map((t) -> new ConditionOutcome(t == required,
message.found("spring.session.store-type property").items(t)))
.orElse(ConditionOutcome.noMatch(message.didNotFind("spring.session.store-type property").atAll()));
.orElseGet(() -> ConditionOutcome
.noMatch(message.didNotFind("spring.session.store-type property").atAll()));
}
catch (BindException ex) {
return ConditionOutcome.noMatch(message.found("invalid spring.session.store-type property").atAll());

View File

@@ -97,7 +97,7 @@ public class Profiles implements Iterable<String> {
if (hasExplicit(supplier, propertyValue, unset)) {
return supplier.get();
}
return binder.bind(propertyName, String[].class).orElse(StringUtils.toStringArray(unset));
return binder.bind(propertyName, String[].class).orElseGet(() -> StringUtils.toStringArray(unset));
}
private boolean hasExplicit(Supplier<String[]> supplier, String propertyValue, Set<String> unset) {