2525/**可远程调用的函数类
2626 * @author Lemon
2727 */
28- public class AbstractFunctionParser implements FunctionParser {
28+ public class AbstractFunctionParser < T extends Object > implements FunctionParser < T > {
2929 private static final String TAG = "AbstractFunctionParser" ;
3030
3131 /**是否解析参数 key 的对应的值,不用手动编码 curObj.getString(key)
@@ -65,15 +65,15 @@ public AbstractFunctionParser(RequestMethod method, String tag, int version, @No
6565 setRequest (request );
6666 }
6767
68- private Parser <? > parser ;
68+ private Parser <T > parser ;
6969
7070 @ Override
71- public Parser <? > getParser () {
71+ public Parser <T > getParser () {
7272 return parser ;
7373 }
7474
7575 @ Override
76- public AbstractFunctionParser setParser (Parser <? > parser ) {
76+ public AbstractFunctionParser < T > setParser (Parser <T > parser ) {
7777 this .parser = parser ;
7878 return this ;
7979 }
@@ -84,7 +84,7 @@ public RequestMethod getMethod() {
8484 }
8585
8686 @ Override
87- public AbstractFunctionParser setMethod (RequestMethod method ) {
87+ public AbstractFunctionParser < T > setMethod (RequestMethod method ) {
8888 this .method = method ;
8989 return this ;
9090 }
@@ -95,7 +95,7 @@ public String getTag() {
9595 }
9696
9797 @ Override
98- public AbstractFunctionParser setTag (String tag ) {
98+ public AbstractFunctionParser < T > setTag (String tag ) {
9999 this .tag = tag ;
100100 return this ;
101101 }
@@ -106,7 +106,7 @@ public int getVersion() {
106106 }
107107
108108 @ Override
109- public AbstractFunctionParser setVersion (int version ) {
109+ public AbstractFunctionParser < T > setVersion (int version ) {
110110 this .version = version ;
111111 return this ;
112112 }
@@ -119,7 +119,7 @@ public String getKey() {
119119 }
120120
121121 @ Override
122- public AbstractFunctionParser setKey (String key ) {
122+ public AbstractFunctionParser < T > setKey (String key ) {
123123 this .key = key ;
124124 return this ;
125125 }
@@ -132,7 +132,7 @@ public String getParentPath() {
132132 }
133133
134134 @ Override
135- public AbstractFunctionParser setParentPath (String parentPath ) {
135+ public AbstractFunctionParser < T > setParentPath (String parentPath ) {
136136 this .parentPath = parentPath ;
137137 return this ;
138138 }
@@ -145,7 +145,7 @@ public String getCurrentName() {
145145 }
146146
147147 @ Override
148- public AbstractFunctionParser setCurrentName (String currentName ) {
148+ public AbstractFunctionParser < T > setCurrentName (String currentName ) {
149149 this .currentName = currentName ;
150150 return this ;
151151 }
@@ -157,7 +157,7 @@ public JSONObject getRequest() {
157157 }
158158
159159 @ Override
160- public AbstractFunctionParser setRequest (@ NotNull JSONObject request ) {
160+ public AbstractFunctionParser < T > setRequest (@ NotNull JSONObject request ) {
161161 this .request = request ;
162162 return this ;
163163 }
@@ -171,7 +171,7 @@ public JSONObject getCurrentObject() {
171171 }
172172
173173 @ Override
174- public AbstractFunctionParser setCurrentObject (@ NotNull JSONObject currentObject ) {
174+ public AbstractFunctionParser < T > setCurrentObject (@ NotNull JSONObject currentObject ) {
175175 this .currentObject = currentObject ;
176176 return this ;
177177 }
@@ -294,7 +294,7 @@ public <T extends Object> T getArgVal(String path, Class<T> clazz) {
294294 /**根据路径取值
295295 * @param path
296296 * @param clazz
297- * @param tryAll false-仅当前对象,true-本次请求的全局对象以及 Parser 缓存值
297+ * @param tryAll false-仅当前对象,true-本次请求的全局对象以及 Parser<T> 缓存值
298298 * @return
299299 * @param <T>
300300 */
@@ -342,14 +342,14 @@ public Object invoke(@NotNull String function, @NotNull JSONObject currentObject
342342 public Object invoke (@ NotNull String function , @ NotNull JSONObject currentObject , boolean containRaw ) throws Exception {
343343 return invoke (this , function , currentObject , containRaw );
344344 }
345-
345+
346346 /**反射调用
347347 * @param parser
348348 * @param function 例如get(Map:map,key),参数只允许引用,不能直接传值
349349 * @param currentObject
350350 * @return {@link #invoke(AbstractFunctionParser, String, Class[], Object[])}
351351 */
352- public static Object invoke (@ NotNull AbstractFunctionParser parser , @ NotNull String function , @ NotNull JSONObject currentObject , boolean containRaw ) throws Exception {
352+ public static < T extends Object > Object invoke (@ NotNull AbstractFunctionParser < T > parser , @ NotNull String function , @ NotNull JSONObject currentObject , boolean containRaw ) throws Exception {
353353 if (ENABLE_REMOTE_FUNCTION == false ) {
354354 throw new UnsupportedOperationException ("AbstractFunctionParser.ENABLE_REMOTE_FUNCTION" +
355355 " == false 时不支持远程函数!如需支持则设置 AbstractFunctionParser.ENABLE_REMOTE_FUNCTION = true !" );
@@ -369,9 +369,9 @@ public static Object invoke(@NotNull AbstractFunctionParser parser, @NotNull Str
369369 throw new UnsupportedOperationException ("language = " + language + " 不合法!AbstractFunctionParser.ENABLE_SCRIPT_FUNCTION" +
370370 " == false 时不支持远程函数中的脚本形式!如需支持则设置 AbstractFunctionParser.ENABLE_SCRIPT_FUNCTION = true !" );
371371 }
372-
372+
373373 if (lang != null && SCRIPT_EXECUTOR_MAP .get (lang ) == null ) {
374- throw new ClassNotFoundException ("找不到脚本语言 " + lang + " 对应的执行引擎!请先依赖相关库并在后端 APIJSONFunctionParser 中注册!" );
374+ throw new ClassNotFoundException ("找不到脚本语言 " + lang + " 对应的执行引擎!请先依赖相关库并在后端 APIJSONFunctionParser<T> 中注册!" );
375375 }
376376
377377 int version = row .getIntValue ("version" );
@@ -413,7 +413,7 @@ public static Object invoke(@NotNull AbstractFunctionParser parser, @NotNull Str
413413 }
414414
415415 }
416-
416+
417417 /**反射调用
418418 * @param parser
419419 * @param methodName
@@ -422,7 +422,7 @@ public static Object invoke(@NotNull AbstractFunctionParser parser, @NotNull Str
422422 * @return {@link #invoke(AbstractFunctionParser, String, Class[], Object[], String, JSONObject, ScriptExecutor)}
423423 * @throws Exception
424424 */
425- public static Object invoke (@ NotNull AbstractFunctionParser parser , @ NotNull String methodName
425+ public static < T extends Object > Object invoke (@ NotNull AbstractFunctionParser < T > parser , @ NotNull String methodName
426426 , @ NotNull Class <?>[] parameterTypes , @ NotNull Object [] args ) throws Exception {
427427 return invoke (parser , methodName , parameterTypes , args , null , null , null );
428428 }
@@ -437,7 +437,7 @@ public static Object invoke(@NotNull AbstractFunctionParser parser, @NotNull Str
437437 * @return
438438 * @throws Exception
439439 */
440- public static Object invoke (@ NotNull AbstractFunctionParser parser , @ NotNull String methodName
440+ public static < T extends Object > Object invoke (@ NotNull AbstractFunctionParser < T > parser , @ NotNull String methodName
441441 , @ NotNull Class <?>[] parameterTypes , @ NotNull Object [] args , String returnType
442442 , JSONObject currentObject , ScriptExecutor scriptExecutor ) throws Exception {
443443 if (scriptExecutor != null ) {
@@ -474,7 +474,7 @@ public static Object invoke(@NotNull AbstractFunctionParser parser, @NotNull Str
474474 * @return
475475 * @throws Exception
476476 */
477- public static Object invokeScript (@ NotNull AbstractFunctionParser parser , @ NotNull String methodName
477+ public static < T extends Object > Object invokeScript (@ NotNull AbstractFunctionParser < T > parser , @ NotNull String methodName
478478 , @ NotNull Class <?>[] parameterTypes , @ NotNull Object [] args , String returnType , JSONObject currentObject , ScriptExecutor scriptExecutor ) throws Exception {
479479 Object result = scriptExecutor .execute (parser , currentObject , methodName , args );
480480 if (Log .DEBUG && result != null ) {
0 commit comments