We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
尝试给 ArgumentsRunner 增加对未标注 @Argument 注解的参数,或标注了特定注解的参数注入对象的功能,类似于 Spring 的参数绑定一样。 详细计划的细节稍后补充。
ArgumentsRunner
@Argument
The text was updated successfully, but these errors were encountered:
给这个功能举个例子:
public class MainCommand { @Command() public int getRandomNumber(@Argument(name = "max") int max, Random random) { if(random == null) { random = new Random(); } return random.nextInt(max); } }
random是一个没有类型对应StringParameterParser,也没有@Argument注解的参数,但ArgumentsRunner的调用方在调用run方法的时候可以传递一组对象进去,例如:
random
StringParameterParser
run
Set<Object> objectSet = new HashSet<>(); objectSet.add(new Random()); new ArgumentsRunner(MainCommand.class).run(new MainCommand(), objectSet);
这样 MainCommand.getRandomNumber 方法的random参数就不会为null,而是传入了objectSet里的Random对象。 这个设计有一些问题或前提要求:
MainCommand.getRandomNumber
null
objectSet
Random
Spring
@Autowired
Sorry, something went wrong.
或许可以仅限制generateParamListByFlag返回的List长度满足带@Argument注解参数的数量即可,然后再进行补充? 如果可以的话,打算先让ArgumentsRunner内的参数解析部分模块化后再这么做(如果确定要这么做的话)。
generateParamListByFlag
LamGC
No branches or pull requests
尝试给
ArgumentsRunner
增加对未标注@Argument
注解的参数,或标注了特定注解的参数注入对象的功能,类似于 Spring 的参数绑定一样。详细计划的细节稍后补充。
The text was updated successfully, but these errors were encountered: