You should set things like isCanBeConsumed = true when creating the configuration, so the question of whether to call get() on that Provider is moot.
That said, it's important to understand that, specifically with Configurations, they really aren't ever lazy. This is a case where the "rule" becomes a "guideline." Configurations are always eager, so it's basically OK to use create() and all {} for this type of container.
Also totally missing how map and flatMap differ.
flatMap is when you're mapping over another Provider, so it just "flattens" the provider chain.
I have a spot where I need to see if a configuration exists already, and if not create it.
You should set things like
isCanBeConsumed = true
when creating the configuration, so the question of whether to callget()
on that Provider is moot.That said, it's important to understand that, specifically with
Configuration
s, they really aren't ever lazy. This is a case where the "rule" becomes a "guideline." Configurations are always eager, so it's basically OK to usecreate()
andall {}
for this type of container.flatMap
is when you're mapping over another Provider, so it just "flattens" the provider chain.You can use
maybeCreate()
for this use-case.Thanks for the follow-up