1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.generator.internal;
17
18 import org.mybatis.generator.api.DAOMethodNameCalculator;
19 import org.mybatis.generator.api.IntrospectedTable;
20 import org.mybatis.generator.internal.rules.Rules;
21
22
23
24
25
26 public class ExtendedDAOMethodNameCalculator implements DAOMethodNameCalculator {
27
28
29
30
31 public ExtendedDAOMethodNameCalculator() {
32 super();
33 }
34
35 public String getInsertMethodName(IntrospectedTable introspectedTable) {
36 StringBuilder sb = new StringBuilder();
37 sb.append("insert");
38 sb.append(introspectedTable.getFullyQualifiedTable()
39 .getDomainObjectName());
40
41 return sb.toString();
42 }
43
44
45
46
47
48
49
50
51 public String getUpdateByPrimaryKeyWithoutBLOBsMethodName(
52 IntrospectedTable introspectedTable) {
53 StringBuilder sb = new StringBuilder();
54
55 sb.append("update");
56 sb.append(introspectedTable.getFullyQualifiedTable()
57 .getDomainObjectName());
58
59 Rules rules = introspectedTable.getRules();
60
61 if (!rules.generateUpdateByPrimaryKeyWithBLOBs()) {
62 sb.append("ByPrimaryKey");
63 } else if (rules.generateRecordWithBLOBsClass()) {
64 sb.append("ByPrimaryKey");
65 } else {
66 sb.append("ByPrimaryKeyWithoutBLOBs");
67 }
68
69 return sb.toString();
70 }
71
72
73
74
75
76
77
78
79 public String getUpdateByPrimaryKeyWithBLOBsMethodName(
80 IntrospectedTable introspectedTable) {
81 StringBuilder sb = new StringBuilder();
82 sb.append("update");
83 sb.append(introspectedTable.getFullyQualifiedTable()
84 .getDomainObjectName());
85
86 Rules rules = introspectedTable.getRules();
87
88 if (!rules.generateUpdateByPrimaryKeyWithoutBLOBs()) {
89 sb.append("ByPrimaryKey");
90 } else if (rules.generateRecordWithBLOBsClass()) {
91 sb.append("ByPrimaryKey");
92 } else {
93 sb.append("ByPrimaryKeyWithBLOBs");
94 }
95
96 return sb.toString();
97 }
98
99 public String getDeleteByExampleMethodName(
100 IntrospectedTable introspectedTable) {
101 StringBuilder sb = new StringBuilder();
102 sb.append("delete");
103 sb.append(introspectedTable.getFullyQualifiedTable()
104 .getDomainObjectName());
105 sb.append("ByExample");
106
107 return sb.toString();
108 }
109
110 public String getDeleteByPrimaryKeyMethodName(
111 IntrospectedTable introspectedTable) {
112 StringBuilder sb = new StringBuilder();
113 sb.append("delete");
114 sb.append(introspectedTable.getFullyQualifiedTable()
115 .getDomainObjectName());
116 sb.append("ByPrimaryKey");
117
118 return sb.toString();
119 }
120
121
122
123
124
125
126 public String getSelectByExampleWithoutBLOBsMethodName(
127 IntrospectedTable introspectedTable) {
128 StringBuilder sb = new StringBuilder();
129 sb.append("select");
130 sb.append(introspectedTable.getFullyQualifiedTable()
131 .getDomainObjectName());
132 sb.append("ByExample");
133
134 Rules rules = introspectedTable.getRules();
135
136 if (rules.generateSelectByExampleWithBLOBs()) {
137 sb.append("WithoutBLOBs");
138 }
139
140 return sb.toString();
141 }
142
143
144
145
146
147
148 public String getSelectByExampleWithBLOBsMethodName(
149 IntrospectedTable introspectedTable) {
150 StringBuilder sb = new StringBuilder();
151 sb.append("select");
152 sb.append(introspectedTable.getFullyQualifiedTable()
153 .getDomainObjectName());
154 sb.append("ByExample");
155
156 Rules rules = introspectedTable.getRules();
157
158 if (rules.generateSelectByExampleWithoutBLOBs()) {
159 sb.append("WithBLOBs");
160 }
161
162 return sb.toString();
163 }
164
165 public String getSelectByPrimaryKeyMethodName(
166 IntrospectedTable introspectedTable) {
167 StringBuilder sb = new StringBuilder();
168 sb.append("select");
169 sb.append(introspectedTable.getFullyQualifiedTable()
170 .getDomainObjectName());
171 sb.append("ByPrimaryKey");
172
173 return sb.toString();
174 }
175
176 public String getUpdateByPrimaryKeySelectiveMethodName(
177 IntrospectedTable introspectedTable) {
178 StringBuilder sb = new StringBuilder();
179 sb.append("update");
180 sb.append(introspectedTable.getFullyQualifiedTable()
181 .getDomainObjectName());
182 sb.append("ByPrimaryKeySelective");
183
184 return sb.toString();
185 }
186
187 public String getCountByExampleMethodName(
188 IntrospectedTable introspectedTable) {
189 StringBuilder sb = new StringBuilder();
190 sb.append("count");
191 sb.append(introspectedTable.getFullyQualifiedTable()
192 .getDomainObjectName());
193 sb.append("ByExample");
194
195 return sb.toString();
196 }
197
198 public String getUpdateByExampleSelectiveMethodName(
199 IntrospectedTable introspectedTable) {
200 StringBuilder sb = new StringBuilder();
201 sb.append("update");
202 sb.append(introspectedTable.getFullyQualifiedTable()
203 .getDomainObjectName());
204 sb.append("ByExampleSelective");
205
206 return sb.toString();
207 }
208
209 public String getUpdateByExampleWithBLOBsMethodName(
210 IntrospectedTable introspectedTable) {
211 StringBuilder sb = new StringBuilder();
212 sb.append("update");
213 sb.append(introspectedTable.getFullyQualifiedTable()
214 .getDomainObjectName());
215
216 Rules rules = introspectedTable.getRules();
217
218 if (!rules.generateUpdateByExampleWithoutBLOBs()) {
219 sb.append("ByExample");
220 } else if (rules.generateRecordWithBLOBsClass()) {
221 sb.append("ByExample");
222 } else {
223 sb.append("ByExampleWithBLOBs");
224 }
225
226 return sb.toString();
227 }
228
229 public String getUpdateByExampleWithoutBLOBsMethodName(
230 IntrospectedTable introspectedTable) {
231 StringBuilder sb = new StringBuilder();
232
233 sb.append("update");
234 sb.append(introspectedTable.getFullyQualifiedTable()
235 .getDomainObjectName());
236
237 Rules rules = introspectedTable.getRules();
238
239 if (!rules.generateUpdateByExampleWithBLOBs()) {
240 sb.append("ByExample");
241 } else if (rules.generateRecordWithBLOBsClass()) {
242 sb.append("ByExample");
243 } else {
244 sb.append("ByExampleWithoutBLOBs");
245 }
246
247 return sb.toString();
248 }
249
250 public String getInsertSelectiveMethodName(
251 IntrospectedTable introspectedTable) {
252 StringBuilder sb = new StringBuilder();
253 sb.append("insert");
254 sb.append(introspectedTable.getFullyQualifiedTable()
255 .getDomainObjectName());
256 sb.append("Selective");
257
258 return sb.toString();
259 }
260 }