View Javadoc
1   /*
2    *    Copyright 2006-2023 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.internal.db;
17  
18  import static org.mybatis.generator.internal.util.StringUtility.composeFullyQualifiedTableName;
19  
20  /**
21   * This class holds the actual catalog, schema, and table name returned from the
22   * database introspection.
23   *
24   * @author Jeff Butler
25   */
26  public class ActualTableName {
27  
28      private final String tableName;
29      private final String catalog;
30      private final String schema;
31      private final String fullName;
32  
33      public ActualTableName(String catalog, String schema, String tableName) {
34          this.catalog = catalog;
35          this.schema = schema;
36          this.tableName = tableName;
37          fullName = composeFullyQualifiedTableName(catalog,
38                  schema, tableName, '.');
39      }
40  
41      public String getCatalog() {
42          return catalog;
43      }
44  
45      public String getSchema() {
46          return schema;
47      }
48  
49      public String getTableName() {
50          return tableName;
51      }
52  
53      @Override
54      public boolean equals(Object obj) {
55          if (!(obj instanceof ActualTableName)) {
56              return false;
57          }
58  
59          return obj.toString().equals(this.toString());
60      }
61  
62      @Override
63      public int hashCode() {
64          return fullName.hashCode();
65      }
66  
67      @Override
68      public String toString() {
69          return fullName;
70      }
71  }