jcommander
jcommander copied to clipboard
Invoke IDefaultProvider only if needed
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 pername
. - ...only invoked if no explicit value is provided, hence when a default is really to be used.