20
20
import java .util .Iterator ;
21
21
import java .util .List ;
22
22
import java .util .Map ;
23
- import java .util .Optional ;
24
23
25
24
import org .mybatis .generator .api .FullyQualifiedTable ;
26
25
import org .mybatis .generator .api .IntrospectedTable ;
@@ -111,40 +110,6 @@ public boolean sqlMapDocumentGenerated(Document document,
111
110
return true ;
112
111
}
113
112
114
- @ Override
115
- public boolean clientBasicSelectManyMethodGenerated (Method method , Interface interfaze ,
116
- IntrospectedTable introspectedTable ) {
117
- copyAndAddSelectManyMethod (method , interfaze );
118
-
119
- addNewComposedFunction (interfaze , introspectedTable , method );
120
- return true ;
121
- }
122
-
123
- private void addNewComposedFunction (Interface interfaze , IntrospectedTable introspectedTable ,
124
- Method baseMethod ) {
125
- Optional <FullyQualifiedJavaType > methodReturnType = baseMethod .getReturnType ();
126
- if (!methodReturnType .isPresent ()) {
127
- // shouldn't happen, but just in case...
128
- return ;
129
- }
130
-
131
- interfaze .addImportedType (new FullyQualifiedJavaType ("java.util.function.Function" )); //$NON-NLS-1$
132
-
133
- FullyQualifiedJavaType returnType =
134
- new FullyQualifiedJavaType ("Function<SelectStatementProvider, " //$NON-NLS-1$
135
- + methodReturnType .get ().getShortName () + ">" ); //$NON-NLS-1$
136
-
137
- Method method = new Method ("selectManyWithRowbounds" ); //$NON-NLS-1$
138
- method .setDefault (true );
139
- method .setReturnType (returnType );
140
- method .addParameter (new Parameter (rowBounds , "rowBounds" )); //$NON-NLS-1$
141
- method .addBodyLine (
142
- "return selectStatement -> selectManyWithRowbounds(selectStatement, rowBounds);" ); //$NON-NLS-1$
143
- context .getCommentGenerator ().addGeneralMethodAnnotation (
144
- method , introspectedTable , interfaze .getImportedTypes ());
145
- interfaze .addMethod (method );
146
- }
147
-
148
113
/**
149
114
* Use the method copy constructor to create a new method, then
150
115
* add the rowBounds parameter.
@@ -160,51 +125,6 @@ private void copyAndAddMethod(Method method, Interface interfaze) {
160
125
interfaze .addImportedType (rowBounds );
161
126
}
162
127
163
- private void copyAndAddSelectManyMethod (Method method , Interface interfaze ) {
164
- List <String > annotations = new ArrayList <>(method .getAnnotations ());
165
-
166
- // remove the @Results annotation and replace it with @ResultMap
167
- boolean inResultsAnnotation = false ;
168
- String resultMapId = null ;
169
- Iterator <String > iter = annotations .iterator ();
170
- while (iter .hasNext ()) {
171
- String annotation = iter .next ();
172
-
173
- if (inResultsAnnotation ) {
174
- if (annotation .equals ("})" )) { //$NON-NLS-1$
175
- inResultsAnnotation = false ;
176
- }
177
- iter .remove ();
178
- } else if (annotation .startsWith ("@Results(" )) { //$NON-NLS-1$
179
- inResultsAnnotation = true ;
180
- iter .remove ();
181
-
182
- // now find the ID
183
- int index = annotation .indexOf ("id=\" " ); //$NON-NLS-1$
184
- int startIndex = index + "id=\" " .length (); //$NON-NLS-1$
185
- int endIndex = annotation .indexOf ('\"' , startIndex + 1 ); //$NON-NLS-1$
186
- resultMapId = annotation .substring (startIndex , endIndex );
187
- }
188
- }
189
-
190
- if (resultMapId != null ) {
191
- interfaze .addImportedType (
192
- new FullyQualifiedJavaType ("org.apache.ibatis.annotations.ResultMap" )); //$NON-NLS-1$
193
- annotations .add ("@ResultMap(\" " + resultMapId + "\" )" ); //$NON-NLS-1$ //$NON-NLS-2$
194
- }
195
-
196
- Method newMethod = new Method (method );
197
- newMethod .getAnnotations ().clear ();
198
- for (String annotation : annotations ) {
199
- newMethod .addAnnotation (annotation );
200
- }
201
-
202
- newMethod .setName (method .getName () + "WithRowbounds" ); //$NON-NLS-1$
203
- newMethod .addParameter (new Parameter (rowBounds , "rowBounds" )); //$NON-NLS-1$
204
- interfaze .addMethod (newMethod );
205
- interfaze .addImportedType (rowBounds );
206
- }
207
-
208
128
/**
209
129
* Use the method copy constructor to create a new element.
210
130
*
0 commit comments