• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / generator / 2057

16 Feb 2026 08:58PM UTC coverage: 90.025% (+0.1%) from 89.916%
2057

push

github

web-flow
Merge pull request #1454 from jeffgbutler/generate-records

Support Generating JDK 16 Records in All Runtimes

2335 of 3103 branches covered (75.25%)

153 of 161 new or added lines in 31 files covered. (95.03%)

2 existing lines in 1 file now uncovered.

11633 of 12922 relevant lines covered (90.02%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

22.73
/core/mybatis-generator-core/src/main/java/org/mybatis/generator/api/CommentGenerator.java
1
/*
2
 *    Copyright 2006-2026 the original author or authors.
3
 *
4
 *    Licensed under the Apache License, Version 2.0 (the "License");
5
 *    you may not use this file except in compliance with the License.
6
 *    You may obtain a copy of the License at
7
 *
8
 *       https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *    Unless required by applicable law or agreed to in writing, software
11
 *    distributed under the License is distributed on an "AS IS" BASIS,
12
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *    See the License for the specific language governing permissions and
14
 *    limitations under the License.
15
 */
16
package org.mybatis.generator.api;
17

18
import java.util.Properties;
19
import java.util.Set;
20

21
import org.mybatis.generator.api.dom.java.CompilationUnit;
22
import org.mybatis.generator.api.dom.java.Field;
23
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
24
import org.mybatis.generator.api.dom.java.InnerClass;
25
import org.mybatis.generator.api.dom.java.InnerEnum;
26
import org.mybatis.generator.api.dom.java.InnerRecord;
27
import org.mybatis.generator.api.dom.java.Method;
28
import org.mybatis.generator.api.dom.java.TopLevelClass;
29
import org.mybatis.generator.api.dom.kotlin.KotlinFile;
30
import org.mybatis.generator.api.dom.kotlin.KotlinFunction;
31
import org.mybatis.generator.api.dom.kotlin.KotlinProperty;
32
import org.mybatis.generator.api.dom.kotlin.KotlinType;
33
import org.mybatis.generator.api.dom.xml.XmlElement;
34

35
/**
36
 * Implementations of this interface are used to generate comments for the
37
 * various artifacts.
38
 *
39
 * @author Jeff Butler
40
 */
41
public interface CommentGenerator {
42

43
    /**
44
     * Adds properties for this instance from any properties configured in the
45
     * CommentGenerator configuration.
46
     *
47
     * <p>This method will be called before any of the other methods.
48
     *
49
     * @param properties
50
     *            All properties from the configuration
51
     */
52
    void addConfigurationProperties(Properties properties);
53

54
    /**
55
     * This method should add a Javadoc comment to the specified field. The field is related to the
56
     * specified table and is used to hold the value of the specified column.
57
     *
58
     * <p><b>Important:</b> This method should add the nonstandard JavaDoc tag "@mbg.generated" to
59
     * the comment. Without this tag, the Eclipse based Java merge feature will fail.
60
     *
61
     * @param field
62
     *            the field
63
     * @param introspectedTable
64
     *            the introspected table
65
     * @param introspectedColumn
66
     *            the introspected column
67
     */
68
    default void addFieldComment(Field field,
69
            IntrospectedTable introspectedTable,
70
            IntrospectedColumn introspectedColumn) {}
×
71

72
    /**
73
     * Adds the field comment.
74
     *
75
     * @param field
76
     *            the field
77
     * @param introspectedTable
78
     *            the introspected table
79
     */
80
    default void addFieldComment(Field field, IntrospectedTable introspectedTable) {}
×
81

82
    /**
83
     * Adds a comment for a model class.  The Java code merger should
84
     * be notified not to delete the entire class in case any manual
85
     * changes have been made.  So this method will always use the
86
     * "do not delete" annotation.
87
     *
88
     * <p>Because of difficulties with the Java file merger, the default implementation
89
     * of this method should NOT add comments.  Comments should only be added if
90
     * specifically requested by the user (for example, by enabling table remark comments).
91
     *
92
     * @param topLevelClass
93
     *            the top level class
94
     * @param introspectedTable
95
     *            the introspected table
96
     */
97
    default void addModelClassComment(TopLevelClass topLevelClass,
98
            IntrospectedTable introspectedTable) {}
×
99

100
    /**
101
     * Adds a comment for a model class.
102
     *
103
     * @param modelClass
104
     *            the generated KotlinType for the model
105
     * @param introspectedTable
106
     *            the introspected table
107
     */
108
    default void addModelClassComment(KotlinType modelClass,
109
            IntrospectedTable introspectedTable) {}
1✔
110

111
    /**
112
     * Adds the inner class comment.
113
     *
114
     * @param innerClass
115
     *            the inner class
116
     * @param introspectedTable
117
     *            the introspected table
118
     */
119
    default void addClassComment(InnerClass innerClass,
120
            IntrospectedTable introspectedTable) {}
×
121

122
    /**
123
     * Adds the inner class comment.
124
     *
125
     * @param innerClass
126
     *            the inner class
127
     * @param introspectedTable
128
     *            the introspected table
129
     * @param markAsDoNotDelete
130
     *            the mark as do not delete
131
     */
132
    default void addClassComment(InnerClass innerClass,
133
            IntrospectedTable introspectedTable, boolean markAsDoNotDelete) {}
×
134

135
    /**
136
     * Adds the enum comment.
137
     *
138
     * @param innerEnum
139
     *            the inner enum
140
     * @param introspectedTable
141
     *            the introspected table
142
     */
143
    default void addEnumComment(InnerEnum innerEnum,
144
            IntrospectedTable introspectedTable) {}
×
145

146
    /**
147
     * Adds the getter comment.
148
     *
149
     * @param method
150
     *            the method
151
     * @param introspectedTable
152
     *            the introspected table
153
     * @param introspectedColumn
154
     *            the introspected column
155
     */
156
    default void addGetterComment(Method method,
157
            IntrospectedTable introspectedTable,
158
            IntrospectedColumn introspectedColumn) {}
×
159

160
    /**
161
     * Adds the setter comment.
162
     *
163
     * @param method
164
     *            the method
165
     * @param introspectedTable
166
     *            the introspected table
167
     * @param introspectedColumn
168
     *            the introspected column
169
     */
170
    default void addSetterComment(Method method,
171
            IntrospectedTable introspectedTable,
172
            IntrospectedColumn introspectedColumn) {}
×
173

174
    /**
175
     * Adds the general method comment.
176
     *
177
     * @param method
178
     *            the method
179
     * @param introspectedTable
180
     *            the introspected table
181
     */
182
    default void addGeneralMethodComment(Method method,
183
            IntrospectedTable introspectedTable) {}
×
184

185
    /**
186
     * This method is called to add a file level comment to a generated java file. This method
187
     * could be used to add a general file comment (such as a copyright notice). However, note
188
     * that the Java file merge function in Eclipse does not deal with this comment. If you run
189
     * the generator repeatedly, you will only retain the comment from the initial run.
190
     *
191
     * <p>The default implementation does nothing.
192
     *
193
     * @param compilationUnit
194
     *            the compilation unit
195
     */
196
    default void addJavaFileComment(CompilationUnit compilationUnit) {}
1✔
197

198
    /**
199
     * This method should add a suitable comment as a child element of the specified xmlElement to warn users that the
200
     * element was generated and is subject to regeneration.
201
     *
202
     * @param xmlElement
203
     *            the xml element
204
     */
205
    default void addComment(XmlElement xmlElement) {}
×
206

207
    /**
208
     * This method is called to add a comment as the first child of the root element. This method
209
     * could be used to add a general file comment (such as a copyright notice). However, note
210
     * that the XML file merge function does not deal with this comment. If you run the generator
211
     * repeatedly, you will only retain the comment from the initial run.
212
     *
213
     * <p>The default implementation does nothing.
214
     *
215
     * @param rootElement
216
     *            the root element
217
     */
218
    default void addRootComment(XmlElement rootElement) {}
1✔
219

220
    /**
221
     * Adds a @Generated annotation to a method.
222
     *
223
     * @param method
224
     *            the method
225
     * @param introspectedTable
226
     *            the introspected table
227
     * @param imports
228
     *     the comment generator may add a required imported type to this list
229
     *
230
     * @since 1.3.6
231
     */
232
    default void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable,
233
            Set<FullyQualifiedJavaType> imports) {}
×
234

235
    /**
236
     * Adds a @Generated annotation to a method.
237
     *
238
     * @param method
239
     *            the method
240
     * @param introspectedTable
241
     *            the introspected table
242
     * @param introspectedColumn
243
     *     thr introspected column
244
     * @param imports
245
     *     the comment generator may add a required imported type to this list
246
     *
247
     * @since 1.3.6
248
     */
249
    default void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable,
250
            IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) {}
×
251

252
    /**
253
     * Adds a @Generated annotation to a field.
254
     *
255
     * @param field
256
     *            the field
257
     * @param introspectedTable
258
     *            the introspected table
259
     * @param imports
260
     *     the comment generator may add a required imported type to this list
261
     *
262
     * @since 1.3.6
263
     */
264
    default void addFieldAnnotation(Field field, IntrospectedTable introspectedTable,
265
            Set<FullyQualifiedJavaType> imports) {}
×
266

267
    /**
268
     * Adds a @Generated annotation to a field.
269
     *
270
     * @param field
271
     *            the field
272
     * @param introspectedTable
273
     *            the introspected table
274
     * @param introspectedColumn
275
     *            the introspected column
276
     * @param imports
277
     *     the comment generator may add a required imported type to this list
278
     *
279
     * @since 1.3.6
280
     */
281
    default void addFieldAnnotation(Field field, IntrospectedTable introspectedTable,
282
            IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) {}
×
283

284
    /**
285
     * Adds a @Generated annotation to a class.
286
     *
287
     * @param innerClass
288
     *            the class
289
     * @param introspectedTable
290
     *            the introspected table
291
     * @param imports
292
     *     the comment generator may add a required imported type to this list
293
     *
294
     * @since 1.3.6
295
     */
296
    default void addClassAnnotation(InnerClass innerClass, IntrospectedTable introspectedTable,
297
            Set<FullyQualifiedJavaType> imports) {}
×
298

299
    /**
300
     * Adds a @Generated annotation to a record.
301
     *
302
     * @param innerRecord
303
     *            the record
304
     * @param introspectedTable
305
     *            the introspected table
306
     * @param imports
307
     *     the comment generator may add a required imported type to this list
308
     *
309
     * @since 2.0.0
310
     */
311
    default void addRecordAnnotation(InnerRecord innerRecord, IntrospectedTable introspectedTable,
NEW
312
                                     Set<FullyQualifiedJavaType> imports) {}
×
313

314
    /**
315
     * This method is called to add a file level comment to a generated Kotlin file. This method
316
     * could be used to add a general file comment (such as a copyright notice).
317
     *
318
     * <p>The default implementation does nothing.
319
     *
320
     * @param kotlinFile
321
     *            the Kotlin file
322
     */
323
    default void addFileComment(KotlinFile kotlinFile) {}
×
324

325
    default void addGeneralFunctionComment(KotlinFunction kf, IntrospectedTable introspectedTable,
326
            Set<String> imports) {}
1✔
327

328
    default void addGeneralPropertyComment(KotlinProperty property, IntrospectedTable introspectedTable,
329
            Set<String> imports) {}
1✔
330
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc