Instantiator icon indicating copy to clipboard operation
Instantiator copied to clipboard

Misleading useNull flag

Open engi2nee opened this issue 1 year ago • 6 comments

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.

engi2nee avatar Aug 17 '22 15:08 engi2nee