-
Notifications
You must be signed in to change notification settings - Fork 40
/
MethodModel.java
180 lines (141 loc) · 3.71 KB
/
MethodModel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package org.nebula.contrib.ngbatis.models;
// Copyright (c) 2022 All project authors. All rights reserved.
//
// This source code is licensed under Apache 2.0 License.
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
/**
* XXXDao.java 中的单个方法信息,以及 xml 中 子标签下的文本数据酷操作脚本 CQL
*
* @author yeweicheng
* <br>Now is history!
*/
public class MethodModel {
// ---------------- info in xml start ---------------------
/**
* 方法名
*/
private String id;
/**
* nGQL 模板
*/
private String text; // cql
/**
* 在方法中指定使用的 space
*/
private String space;
/**
* xml 中配置的参数类型
*/
private Class parameterType;
/**
* xml 中子标签所声明的 集合泛型
*/
private Class resultType;
/**
* 反射所得的方法返回值
*/
private Class returnType;
/**
* 是否从参数中设置空间
*/
private boolean spaceFromParam;
/**
* XXXDao 的方法对象
*/
private Method method;
/**
* {@link #method} 参数列表的参数类型数组
*/
private Class<?>[] parameterTypes;
/**
* {@link #method} 参数列表的参数注解
*/
private Annotation[][] paramAnnotations;
// ---------------- info in interface start ---------------------
/**
* 用于 asm 的方法签名。
*/
private String signature;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getSpace() {
return space;
}
public void setSpace(String space) {
this.space = space;
}
public Class getParameterType() {
return parameterType;
}
public void setParameterType(Class parameterType) {
this.parameterType = parameterType;
}
public Class getResultType() {
return resultType;
}
public void setResultType(Class resultType) {
this.resultType = resultType;
}
public Method getMethod() {
return method;
}
public void setMethod(Method method) {
this.method = method;
}
public String getSignature() {
return signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
public Class<?>[] getParameterTypes() {
return method == null ? parameterTypes : method.getParameterTypes();
}
public void setParameterTypes(Class<?>[] parameterTypes) {
this.parameterTypes = parameterTypes;
}
public Annotation[][] getParamAnnotations() {
return paramAnnotations;
}
public void setParamAnnotations(Annotation[][] paramAnnotations) {
this.paramAnnotations = paramAnnotations;
}
public int getParameterCount() {
return method == null ? parameterTypes.length : method.getParameterCount();
}
public Class getReturnType() {
return method == null ? returnType : method.getReturnType();
}
public void setReturnType(Class returnType) {
this.returnType = returnType;
}
public boolean isSpaceFromParam() {
return spaceFromParam;
}
public void setSpaceFromParam(boolean spaceFromParam) {
this.spaceFromParam = spaceFromParam;
}
/**
* <p>获取方法参数的所有注解。</p>
* @return 方法参数注解
*/
public Annotation[][] getParameterAnnotations() {
if (method != null) {
return method.getParameterAnnotations();
} else if (paramAnnotations != null) {
return paramAnnotations;
}
return new Annotation[getParameterCount()][];
}
}