View Javadoc
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  /**
19   * Abstract class that holds information common to all generated files.
20   *
21   * @author Jeff Butler
22   */
23  public abstract class GeneratedFile {
24      protected final String targetProject;
25  
26      protected GeneratedFile(String targetProject) {
27          this.targetProject = targetProject;
28      }
29  
30      /**
31       * Get the file name (without any path). Clients should use this method to
32       * determine how to save the results.
33       *
34       * @return Returns the file name.
35       */
36      public abstract String getFileName();
37  
38      /**
39       * Gets the target project. Clients can call this method to determine how to
40       * save the results.
41       *
42       * @return the target project
43       */
44      public String getTargetProject() {
45          return targetProject;
46      }
47  
48      /**
49       * Get the target package for the file. Clients should use this method to
50       * determine how to save the results.
51       *
52       * @return Returns the target project.
53       */
54      public abstract String getTargetPackage();
55  
56      @Override
57      public String toString() {
58          return getFileName();
59      }
60  
61      /**
62       * Checks if is mergeable.
63       *
64       * @return true, if is mergeable
65       */
66      public abstract boolean isMergeable();
67  }