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

mybatis / generator / 1646

21 Apr 2025 10:17PM UTC coverage: 88.157% (-0.2%) from 88.328%
1646

push

github

hazendaz
[ci] Run auto formatting

2518 of 3412 branches covered (73.8%)

994 of 1117 new or added lines in 164 files covered. (88.99%)

23 existing lines in 12 files now uncovered.

10578 of 11999 relevant lines covered (88.16%)

0.88 hits per line

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

23.81
/core/mybatis-generator-core/src/main/java/org/mybatis/generator/api/CommentGenerator.java
1
/*
2
 *    Copyright 2006-2025 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.Method;
27
import org.mybatis.generator.api.dom.java.TopLevelClass;
28
import org.mybatis.generator.api.dom.kotlin.KotlinFile;
29
import org.mybatis.generator.api.dom.kotlin.KotlinFunction;
30
import org.mybatis.generator.api.dom.kotlin.KotlinProperty;
31
import org.mybatis.generator.api.dom.kotlin.KotlinType;
32
import org.mybatis.generator.api.dom.xml.XmlElement;
33

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

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

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

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

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

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

107
    /**
108
     * Adds the inner class comment.
109
     *
110
     * @param innerClass
111
     *            the inner class
112
     * @param introspectedTable
113
     *            the introspected table
114
     */
115
    default void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) {
NEW
116
    }
×
117

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

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

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

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

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

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

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

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

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

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

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

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

303
    /**
304
     * This method is called to add a file level comment to a generated Kotlin file. This method could be used to add a
305
     * general file comment (such as a copyright notice).
306
     * <p>
307
     * The default implementation does nothing.
308
     *
309
     * @param kotlinFile
310
     *            the Kotlin file
311
     */
312
    default void addFileComment(KotlinFile kotlinFile) {
NEW
313
    }
×
314

315
    default void addGeneralFunctionComment(KotlinFunction kf, IntrospectedTable introspectedTable,
316
            Set<String> imports) {
317
    }
1✔
318

319
    default void addGeneralPropertyComment(KotlinProperty property, IntrospectedTable introspectedTable,
320
            Set<String> imports) {
321
    }
1✔
322
}
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

© 2025 Coveralls, Inc