Package org.mybatis.generator.internal
Class DefaultCommentGenerator
java.lang.Object
org.mybatis.generator.internal.DefaultCommentGenerator
- All Implemented Interfaces:
CommentGenerator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanIf suppressAllComments is true, this option is ignored.private SimpleDateFormatprivate FullyQualifiedJavaTypeprivate final Propertiesprivate booleanprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClassAnnotation(InnerClass innerClass, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> imports) Adds a @Generated annotation to a class.voidaddClassComment(InnerClass innerClass, IntrospectedTable introspectedTable) Adds the inner class comment.voidaddClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete) Adds the inner class comment.voidaddComment(XmlElement xmlElement) Adds a suitable comment to warn users that the element was generated, and when it was generated.voidAdds properties for this instance from any properties configured in the CommentGenerator configuration.voidaddEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable) Adds the enum comment.voidaddFieldAnnotation(Field field, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> imports) Adds a @Generated annotation to a field.voidaddFieldAnnotation(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) Adds a @Generated annotation to a field.voidaddFieldComment(Field field, IntrospectedTable introspectedTable) Adds the field comment.voidaddFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) This method should add a Javadoc comment to the specified field.voidaddFileComment(KotlinFile kotlinFile) This method is called to add a file level comment to a generated Kotlin file.voidaddGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> imports) Adds a @Generated annotation to a method.voidaddGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) Adds a @Generated annotation to a method.voidaddGeneralMethodComment(Method method, IntrospectedTable introspectedTable) Adds the general method comment.voidaddGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) Adds the getter comment.protected voidaddJavadocTag(JavaElement javaElement, boolean markAsDoNotDelete) This method adds the custom javadoc tag for.voidaddModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) Adds a comment for a model class.voidaddSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) Adds the setter comment.protected StringReturns a formatted date string to include in the Javadoc tag and XML comments.private StringgetGeneratedAnnotation(String comment) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.mybatis.generator.api.CommentGenerator
addGeneralFunctionComment, addGeneralPropertyComment, addJavaFileComment, addModelClassComment, addRootComment
-
Field Details
-
properties
-
suppressDate
private boolean suppressDate -
suppressAllComments
private boolean suppressAllComments -
addRemarkComments
private boolean addRemarkCommentsIf suppressAllComments is true, this option is ignored. -
dateFormat
-
generatedImport
-
-
Constructor Details
-
DefaultCommentGenerator
public DefaultCommentGenerator()
-
-
Method Details
-
addComment
Adds a suitable comment to warn users that the element was generated, and when it was generated.- Specified by:
addCommentin interfaceCommentGenerator- Parameters:
xmlElement- the xml element
-
addConfigurationProperties
Description copied from interface:CommentGeneratorAdds properties for this instance from any properties configured in the CommentGenerator configuration.This method will be called before any of the other methods.
- Specified by:
addConfigurationPropertiesin interfaceCommentGenerator- Parameters:
props- All properties from the configuration
-
addJavadocTag
This method adds the custom javadoc tag for. You may do nothing if you do not wish to include the Javadoc tag - however, if you do not include the Javadoc tag then the Java merge capability of the eclipse plugin will break.- Parameters:
javaElement- the java elementmarkAsDoNotDelete- the mark as do not delete
-
getDateString
Returns a formatted date string to include in the Javadoc tag and XML comments. You may return null if you do not want the date in these documentation elements.- Returns:
- a string representing the current timestamp, or null
-
addClassComment
Description copied from interface:CommentGeneratorAdds the inner class comment.- Specified by:
addClassCommentin interfaceCommentGenerator- Parameters:
innerClass- the inner classintrospectedTable- the introspected table
-
addClassComment
public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete) Description copied from interface:CommentGeneratorAdds the inner class comment.- Specified by:
addClassCommentin interfaceCommentGenerator- Parameters:
innerClass- the inner classintrospectedTable- the introspected tablemarkAsDoNotDelete- the mark as do not delete
-
addModelClassComment
Description copied from interface:CommentGeneratorAdds a comment for a model class. The Java code merger should be notified not to delete the entire class in case any manual changes have been made. So this method will always use the "do not delete" annotation.Because of difficulties with the Java file merger, the default implementation of this method should NOT add comments. Comments should only be added if specifically requested by the user (for example, by enabling table remark comments).
- Specified by:
addModelClassCommentin interfaceCommentGenerator- Parameters:
topLevelClass- the top level classintrospectedTable- the introspected table
-
addEnumComment
Description copied from interface:CommentGeneratorAdds the enum comment.- Specified by:
addEnumCommentin interfaceCommentGenerator- Parameters:
innerEnum- the inner enumintrospectedTable- the introspected table
-
addFieldComment
public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) Description copied from interface:CommentGeneratorThis method should add a Javadoc comment to the specified field. The field is related to the specified table and is used to hold the value of the specified column.Important: This method should add a the nonstandard JavaDoc tag "@mbg.generated" to the comment. Without this tag, the Eclipse based Java merge feature will fail.
- Specified by:
addFieldCommentin interfaceCommentGenerator- Parameters:
field- the fieldintrospectedTable- the introspected tableintrospectedColumn- the introspected column
-
addFieldComment
Description copied from interface:CommentGeneratorAdds the field comment.- Specified by:
addFieldCommentin interfaceCommentGenerator- Parameters:
field- the fieldintrospectedTable- the introspected table
-
addGeneralMethodComment
Description copied from interface:CommentGeneratorAdds the general method comment.- Specified by:
addGeneralMethodCommentin interfaceCommentGenerator- Parameters:
method- the methodintrospectedTable- the introspected table
-
addGetterComment
public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) Description copied from interface:CommentGeneratorAdds the getter comment.- Specified by:
addGetterCommentin interfaceCommentGenerator- Parameters:
method- the methodintrospectedTable- the introspected tableintrospectedColumn- the introspected column
-
addSetterComment
public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) Description copied from interface:CommentGeneratorAdds the setter comment.- Specified by:
addSetterCommentin interfaceCommentGenerator- Parameters:
method- the methodintrospectedTable- the introspected tableintrospectedColumn- the introspected column
-
addGeneralMethodAnnotation
public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> imports) Description copied from interface:CommentGeneratorAdds a @Generated annotation to a method.- Specified by:
addGeneralMethodAnnotationin interfaceCommentGenerator- Parameters:
method- the methodintrospectedTable- the introspected tableimports- the comment generator may add a required imported type to this list
-
addGeneralMethodAnnotation
public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) Description copied from interface:CommentGeneratorAdds a @Generated annotation to a method.- Specified by:
addGeneralMethodAnnotationin interfaceCommentGenerator- Parameters:
method- the methodintrospectedTable- the introspected tableintrospectedColumn- thr introspected columnimports- the comment generator may add a required imported type to this list
-
addFieldAnnotation
public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> imports) Description copied from interface:CommentGeneratorAdds a @Generated annotation to a field.- Specified by:
addFieldAnnotationin interfaceCommentGenerator- Parameters:
field- the fieldintrospectedTable- the introspected tableimports- the comment generator may add a required imported type to this list
-
addFieldAnnotation
public void addFieldAnnotation(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn, Set<FullyQualifiedJavaType> imports) Description copied from interface:CommentGeneratorAdds a @Generated annotation to a field.- Specified by:
addFieldAnnotationin interfaceCommentGenerator- Parameters:
field- the fieldintrospectedTable- the introspected tableintrospectedColumn- the introspected columnimports- the comment generator may add a required imported type to this list
-
addClassAnnotation
public void addClassAnnotation(InnerClass innerClass, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> imports) Description copied from interface:CommentGeneratorAdds a @Generated annotation to a class.- Specified by:
addClassAnnotationin interfaceCommentGenerator- Parameters:
innerClass- the classintrospectedTable- the introspected tableimports- the comment generator may add a required imported type to this list
-
getGeneratedAnnotation
-
addFileComment
Description copied from interface:CommentGeneratorThis method is called to add a file level comment to a generated Kotlin file. This method could be used to add a general file comment (such as a copyright notice).The default implementation does nothing.
- Specified by:
addFileCommentin interfaceCommentGenerator- Parameters:
kotlinFile- the Kotlin file
-