Commit 8e69a821 authored by izeye's avatar izeye Committed by Stephane Nicoll

Use BindResult.orElseGet() where beneficial

See gh-24477
parent d1f2aab1
...@@ -58,7 +58,8 @@ abstract class AbstractSessionCondition extends SpringBootCondition { ...@@ -58,7 +58,8 @@ abstract class AbstractSessionCondition extends SpringBootCondition {
return binder.bind("spring.session.store-type", StoreType.class) return binder.bind("spring.session.store-type", StoreType.class)
.map((t) -> new ConditionOutcome(t == required, .map((t) -> new ConditionOutcome(t == required,
message.found("spring.session.store-type property").items(t))) 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) { catch (BindException ex) {
return ConditionOutcome.noMatch(message.found("invalid spring.session.store-type property").atAll()); return ConditionOutcome.noMatch(message.found("invalid spring.session.store-type property").atAll());
......
...@@ -97,7 +97,7 @@ public class Profiles implements Iterable<String> { ...@@ -97,7 +97,7 @@ public class Profiles implements Iterable<String> {
if (hasExplicit(supplier, propertyValue, unset)) { if (hasExplicit(supplier, propertyValue, unset)) {
return supplier.get(); 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) { private boolean hasExplicit(Supplier<String[]> supplier, String propertyValue, Set<String> unset) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment