Instantiator
Instantiator copied to clipboard
Misleading useNull flag
In the InstantiatorConfig
we can pass useNull
as false, which I expected to fill all nullables with random values.
Then I noticed In the Readme:
If config.useNull = false then InstanceFactor will be called to decide if a null or non-null value is returned.
digging into the code base, I found toNullableInstanceFactory
which is set to use ToNullableInstanceFactoryMode.RANDOM
(Randomly return null
or a Random value
) in all default nullable factories inside DEFAULT_INSTANCE_FACTORIES
, with no way to change it except for new custom factories.
I think useNull
boolean flag should be replaced by a ToNullableInstanceFactoryMode
check, as there is no way to make default nullable factories never return null.