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

mybatis / generator / 2202

05 May 2026 07:27PM UTC coverage: 91.746% (+0.04%) from 91.703%
2202

push

github

web-flow
Merge pull request #1508 from mybatis/renovate/com.github.javaparser-javaparser-core-3.x

Update dependency com.github.javaparser:javaparser-core to v3.28.1

2454 of 3154 branches covered (77.81%)

12038 of 13121 relevant lines covered (91.75%)

0.92 hits per line

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

31.25
/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
    void setIndenter(Indenter indenter);
55

56
    /**
57
     * Adds a comment for a model class.  The Java code merger should
58
     * be notified not to delete the entire class in case any manual
59
     * changes have been made.  So this method will always use the
60
     * "do not delete" annotation.
61
     *
62
     * <p>Because of difficulties with the Java file merger, the default implementation
63
     * of this method should NOT add comments.  Comments should only be added if
64
     * specifically requested by the user (for example, by enabling table remark comments).
65
     *
66
     * @param topLevelClass
67
     *            the top level class
68
     * @param introspectedTable
69
     *            the introspected table
70
     */
71
    default void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {}
×
72

73
    /**
74
     * Adds a comment for a model class.
75
     *
76
     * @param modelClass
77
     *            the generated KotlinType for the model
78
     * @param introspectedTable
79
     *            the introspected table
80
     */
81
    default void addModelClassComment(KotlinType modelClass, IntrospectedTable introspectedTable) {}
1✔
82

83
    /**
84
     * This method is called to add a file level comment to a generated java file. This method
85
     * could be used to add a general file comment (such as a copyright notice). However, note
86
     * that the Java file merge function may not preserve this comment. If you run
87
     * the generator repeatedly, you will only retain the comment from the initial run.
88
     *
89
     * <p>The default implementation does nothing.
90
     *
91
     * @param compilationUnit
92
     *            the compilation unit
93
     */
94
    default void addJavaFileComment(CompilationUnit compilationUnit) {}
1✔
95

96
    /**
97
     * This method should add a suitable comment as a child element of the specified xmlElement to warn users that the
98
     * element was generated and is subject to regeneration.
99
     *
100
     * @param xmlElement
101
     *            the xml element
102
     */
103
    default void addComment(XmlElement xmlElement) {}
×
104

105
    /**
106
     * This method is called to add a comment as the first child of the root element. This method
107
     * could be used to add a general file comment (such as a copyright notice). However, note
108
     * that the XML file merge function does not deal with this comment. If you run the generator
109
     * repeatedly, you will only retain the comment from the initial run.
110
     *
111
     * <p>The default implementation does nothing.
112
     *
113
     * @param rootElement
114
     *            the root element
115
     */
116
    default void addRootComment(XmlElement rootElement) {}
1✔
117

118
    /**
119
     * Adds a @Generated annotation to a method.
120
     *
121
     * @param method
122
     *            the method
123
     * @param introspectedTable
124
     *            the introspected table
125
     * @param imports
126
     *     the comment generator may add a required imported type to this list
127
     *
128
     * @since 1.3.6
129
     */
130
    default void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable,
131
            Set<FullyQualifiedJavaType> imports) {}
×
132

133
    /**
134
     * Adds a @Generated annotation to a method.
135
     *
136
     * @param method
137
     *            the method
138
     * @param introspectedTable
139
     *            the introspected table
140
     * @param introspectedColumn
141
     *     the introspected column
142
     * @param imports
143
     *     the comment generator may add a required imported type to this list
144
     *
145
     * @since 1.3.6
146
     */
147
    default void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable,
148
            IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) {}
×
149

150
    /**
151
     * Adds a @Generated annotation to a field.
152
     *
153
     * @param field
154
     *            the field
155
     * @param introspectedTable
156
     *            the introspected table
157
     * @param imports
158
     *     the comment generator may add a required imported type to this list
159
     *
160
     * @since 1.3.6
161
     */
162
    default void addFieldAnnotation(Field field, IntrospectedTable introspectedTable,
163
            Set<FullyQualifiedJavaType> imports) {}
×
164

165
    /**
166
     * Adds a @Generated annotation to a field.
167
     *
168
     * @param field
169
     *            the field
170
     * @param introspectedTable
171
     *            the introspected table
172
     * @param introspectedColumn
173
     *            the introspected column
174
     * @param imports
175
     *     the comment generator may add a required imported type to this list
176
     *
177
     * @since 1.3.6
178
     */
179
    default void addFieldAnnotation(Field field, IntrospectedTable introspectedTable,
180
            IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) {}
×
181

182
    /**
183
     * Adds a @Generated annotation to a class.
184
     *
185
     * @param innerClass
186
     *            the class
187
     * @param introspectedTable
188
     *            the introspected table
189
     * @param imports
190
     *     the comment generator may add a required imported type to this list
191
     *
192
     * @since 1.3.6
193
     */
194
    default void addClassAnnotation(InnerClass innerClass, IntrospectedTable introspectedTable,
195
            Set<FullyQualifiedJavaType> imports) {}
×
196

197
    /**
198
     * Adds a @Generated annotation to a class and marks it as do not delete. This means that the class should survive
199
     * a Java merge operation even if a newly generated method matches it (the new method will be discarded).
200
     *
201
     * @param innerClass the class
202
     * @param introspectedTable the introspected table
203
     * @param imports
204
     *     the comment generator may add a required imported type to this list
205
     */
206
    default void addClassAnnotationAndMarkAsDoNotDelete(InnerClass innerClass, IntrospectedTable introspectedTable,
207
                                                        Set<FullyQualifiedJavaType> imports) { }
×
208

209
    /**
210
     * Adds a @Generated annotation to a record.
211
     *
212
     * @param innerRecord
213
     *            the record
214
     * @param introspectedTable
215
     *            the introspected table
216
     * @param imports
217
     *     the comment generator may add a required imported type to this list
218
     *
219
     * @since 2.0.0
220
     */
221
    default void addRecordAnnotation(InnerRecord innerRecord, IntrospectedTable introspectedTable,
222
                                     Set<FullyQualifiedJavaType> imports) {}
×
223

224
    /**
225
     * Adds a @Generated annotation to an enum.
226
     *
227
     * @param innerEnum the enum
228
     * @param introspectedTable the introspected table
229
     * @param imports
230
     *     the comment generator may add a required imported type to this list
231
     *
232
     * @since 2.0.0
233
     */
234
    default void addEnumAnnotation(InnerEnum innerEnum, IntrospectedTable introspectedTable,
235
                                   Set<FullyQualifiedJavaType> imports) {}
×
236

237
    /**
238
     * This method is called to add a file level comment to a generated Kotlin file. This method
239
     * could be used to add a general file comment (such as a copyright notice).
240
     *
241
     * <p>The default implementation does nothing.
242
     *
243
     * @param kotlinFile
244
     *            the Kotlin file
245
     */
246
    default void addFileComment(KotlinFile kotlinFile) {}
×
247

248
    default void addGeneralFunctionComment(KotlinFunction kf, IntrospectedTable introspectedTable,
249
            Set<String> imports) {}
1✔
250

251
    default void addGeneralPropertyComment(KotlinProperty property, IntrospectedTable introspectedTable,
252
            Set<String> imports) {}
1✔
253
}
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