Reputation: 11
I want to implement the following logic of Option default value calculation
@Command(name = "test-command")
public class TestCommand implements Callable {
@Autowired
DefaultValueUtils utils;
@ArgGroup
EntityGroup functions = new EntityGroup();
class EntityGroup {
@Option(names = "--function1", defaultValue = "true")
boolean function1 = utils.isFunction1();
@Option(names = "--function2", defaultValue = "true")
boolean function2 = utils.isFunction2();
}
...
}
I have 2 boolean options - function1 and function2; if they are not provided their default values are specified in some other place. But if options provided, I need to override values with provided ones. One more problem is in following logic:
if none of them provided - default values should be calculated; If one of them provided - only provided one is true, not provided false; If both provided - both are true
How can I implement this?
This current block of the code is failing because utils is null during EntityGroup instantiation.
Upvotes: 1
Views: 226