Class DefaultShellCallback

java.lang.Object
org.mybatis.generator.internal.DefaultShellCallback
All Implemented Interfaces:
ShellCallback

public class DefaultShellCallback extends Object implements ShellCallback
  • Constructor Details

    • DefaultShellCallback

      public DefaultShellCallback(boolean overwrite)
  • Method Details

    • getDirectory

      public File getDirectory(String targetProject, String targetPackage) throws ShellException
      Description copied from interface: ShellCallback
      This method is called to ask the shell to resolve a project/package combination into a directory on the file system. This method is called repeatedly (once for each generated file), so it would be wise for an implementing class to cache results.

      The returned java.io.File object:

      • Must be a directory
      • Must exist

      The default shell callback interprets both values as directories and simply concatenates the two values to generate the default directory.

      Specified by:
      getDirectory in interface ShellCallback
      Parameters:
      targetProject - the target project
      targetPackage - the target package
      Returns:
      the directory (must exist)
      Throws:
      ShellException - if the project/package cannot be resolved into a directory on the file system. In this case, the generator will not save the file it is currently working on. The generator will add the exception message to the list of warnings automatically.
    • isOverwriteEnabled

      public boolean isOverwriteEnabled()
      Description copied from interface: ShellCallback
      Return true if the generator should overwrite an existing file if one exists. This method will be called only if isMergeSupported() returns false and a file exists that would be overwritten by a generated file. If you return true, then we will log a warning specifying what file was overwritten.
      Specified by:
      isOverwriteEnabled in interface ShellCallback
      Returns:
      true if you want to overwrite existing files