Andy Wilkinson opened SPR-14980 and commented
When using ObjectProvider with constructor injection, I quite often find myself doing something like this:
public class FooConfiguration {
private final List<FooCustomizer> fooCustomizers;
public FooConfiguration(ObjectProvider<List<FooCustomizer>> fooCustomizersProvider) {
List<FooCustomizer> providedCustomizers = fooCustomizersProvider.getIfAvailable();
this.fooCustomizers = providedCustomizers == null ? Collections.emptyList()
: providedCustomizers;
}
}
I'd quite like to be able to avoid the temporary storage in providedCustomizers and do something like this instead:
public FooConfiguration(ObjectProvider<List<FooCustomizer>> fooCustomizersProvider) {
this.fooCustomizers = fooCustomizersProvider.computeIfAbsent(() -> {
return Collections.emptyList();
});
}
Affects: 5.0 M3
Issue Links:
Andy Wilkinson opened SPR-14980 and commented
When using
ObjectProviderwith constructor injection, I quite often find myself doing something like this:I'd quite like to be able to avoid the temporary storage in
providedCustomizersand do something like this instead:Affects: 5.0 M3
Issue Links: