Class DefaultCommentGenerator

java.lang.Object
org.mybatis.generator.internal.DefaultCommentGenerator
All Implemented Interfaces:
CommentGenerator

public class DefaultCommentGenerator extends Object implements CommentGenerator
  • Constructor Details

    • DefaultCommentGenerator

      public DefaultCommentGenerator()
  • Method Details

    • addComment

      public void addComment(XmlElement xmlElement)
      Adds a suitable comment to warn users that the element was generated, and when it was generated.
      Specified by:
      addComment in interface CommentGenerator
      Parameters:
      xmlElement - the xml element
    • addConfigurationProperties

      public void addConfigurationProperties(Properties props)
      Description copied from interface: CommentGenerator
      Adds 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:
      addConfigurationProperties in interface CommentGenerator
      Parameters:
      props - All properties from the configuration
    • addJavadocTag

      protected void addJavadocTag(JavaElement javaElement, boolean markAsDoNotDelete)
      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 element
      markAsDoNotDelete - the mark as do not delete
    • getDateString

      protected String 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

      public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable)
      Description copied from interface: CommentGenerator
      Adds the inner class comment.
      Specified by:
      addClassComment in interface CommentGenerator
      Parameters:
      innerClass - the inner class
      introspectedTable - the introspected table
    • addClassComment

      public void addClassComment(InnerClass innerClass, IntrospectedTable introspectedTable, boolean markAsDoNotDelete)
      Description copied from interface: CommentGenerator
      Adds the inner class comment.
      Specified by:
      addClassComment in interface CommentGenerator
      Parameters:
      innerClass - the inner class
      introspectedTable - the introspected table
      markAsDoNotDelete - the mark as do not delete
    • addModelClassComment

      public void addModelClassComment(TopLevelClass topLevelClass, IntrospectedTable introspectedTable)
      Description copied from interface: CommentGenerator
      Adds 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:
      addModelClassComment in interface CommentGenerator
      Parameters:
      topLevelClass - the top level class
      introspectedTable - the introspected table
    • addEnumComment

      public void addEnumComment(InnerEnum innerEnum, IntrospectedTable introspectedTable)
      Description copied from interface: CommentGenerator
      Adds the enum comment.
      Specified by:
      addEnumComment in interface CommentGenerator
      Parameters:
      innerEnum - the inner enum
      introspectedTable - the introspected table
    • addFieldComment

      public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn)
      Description copied from interface: CommentGenerator
      This 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:
      addFieldComment in interface CommentGenerator
      Parameters:
      field - the field
      introspectedTable - the introspected table
      introspectedColumn - the introspected column
    • addFieldComment

      public void addFieldComment(Field field, IntrospectedTable introspectedTable)
      Description copied from interface: CommentGenerator
      Adds the field comment.
      Specified by:
      addFieldComment in interface CommentGenerator
      Parameters:
      field - the field
      introspectedTable - the introspected table
    • addGeneralMethodComment

      public void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable)
      Description copied from interface: CommentGenerator
      Adds the general method comment.
      Specified by:
      addGeneralMethodComment in interface CommentGenerator
      Parameters:
      method - the method
      introspectedTable - the introspected table
    • addGetterComment

      public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn)
      Description copied from interface: CommentGenerator
      Adds the getter comment.
      Specified by:
      addGetterComment in interface CommentGenerator
      Parameters:
      method - the method
      introspectedTable - the introspected table
      introspectedColumn - the introspected column
    • addSetterComment

      public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn)
      Description copied from interface: CommentGenerator
      Adds the setter comment.
      Specified by:
      addSetterComment in interface CommentGenerator
      Parameters:
      method - the method
      introspectedTable - the introspected table
      introspectedColumn - the introspected column
    • addGeneralMethodAnnotation

      public void addGeneralMethodAnnotation(Method method, IntrospectedTable introspectedTable, Set<FullyQualifiedJavaType> imports)
      Description copied from interface: CommentGenerator
      Adds a @Generated annotation to a method.
      Specified by:
      addGeneralMethodAnnotation in interface CommentGenerator
      Parameters:
      method - the method
      introspectedTable - the introspected table
      imports - 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: CommentGenerator
      Adds a @Generated annotation to a method.
      Specified by:
      addGeneralMethodAnnotation in interface CommentGenerator
      Parameters:
      method - the method
      introspectedTable - the introspected table
      introspectedColumn - thr introspected column
      imports - 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: CommentGenerator
      Adds a @Generated annotation to a field.
      Specified by:
      addFieldAnnotation in interface CommentGenerator
      Parameters:
      field - the field
      introspectedTable - the introspected table
      imports - 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: CommentGenerator
      Adds a @Generated annotation to a field.
      Specified by:
      addFieldAnnotation in interface CommentGenerator
      Parameters:
      field - the field
      introspectedTable - the introspected table
      introspectedColumn - the introspected column
      imports - 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: CommentGenerator
      Adds a @Generated annotation to a class.
      Specified by:
      addClassAnnotation in interface CommentGenerator
      Parameters:
      innerClass - the class
      introspectedTable - the introspected table
      imports - the comment generator may add a required imported type to this list
    • addFileComment

      public void addFileComment(KotlinFile kotlinFile)
      Description copied from interface: CommentGenerator
      This 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:
      addFileComment in interface CommentGenerator
      Parameters:
      kotlinFile - the Kotlin file