如何在java中获取方法的所有可能返回值?
例:
Object onEvent() {
if (condition) {
return "a";
}
if (condition2) {
return "b";
}
if (condition3) {
return "c";
}
}
Run Code Online (Sandbox Code Playgroud)
我需要这样的东西:
String[] returns = Utils.getReturnStatements("object.onEvent()");
returns = ["a", "b", "c"]
Run Code Online (Sandbox Code Playgroud)
您只能检索方法签名,在这种情况下,它将Object
作为返回类型.
要获得更多详细信息,您需要静态分析源代码或返回类型等enum
.
归档时间: |
|
查看次数: |
4807 次 |
最近记录: |