Skip to content

Commit

Permalink
Merge pull request #24477 from izeye
Browse files Browse the repository at this point in the history
* pr/24477:
  Use BindResult.orElseGet() where beneficial

Closes gh-24477
  • Loading branch information
snicoll committed Dec 15, 2020
2 parents d1f2aab + 8e69a82 commit bf1619e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Expand Up @@ -58,7 +58,8 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
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());
Expand Down
Expand Up @@ -97,7 +97,7 @@ private String[] get(Environment environment, Binder binder, Supplier<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) {
Expand Down

0 comments on commit bf1619e

Please sign in to comment.