jcommander icon indicating copy to clipboard operation
jcommander copied to clipboard

Invoke IDefaultProvider only if needed

Open mkarg opened this issue 5 years ago • 0 comments

Apparently IDefaultProvider is invoked multiple times for the same parameter, once per each of its names, even in case an explicit value is given, i. e. when no default is needed at all.

This is not nice, especially when creation of the default is an expensive operation. For example, when the default provider needs to perform I/O, or expensive cryptographic calculations etc. each default provision invocation might need seconds, while the explicitly provided value for that parameter effectively means "skip all of these costly things"...

Hence it would be great if IDefaultProvider is...

  • ...only invoked once per @Parameter, not once per name.
  • ...only invoked if no explicit value is provided, hence when a default is really to be used.

mkarg avatar Jun 14 '19 07:06 mkarg