View Javadoc
1   /**
2    *    Copyright 2006-2016 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    *       http://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   */
27  public class ActualTableName {
28  
29      private String tableName;
30      private String catalog;
31      private String schema;
32      private String fullName;
33  
34      public ActualTableName(String catalog, String schema, String tableName) {
35          this.catalog = catalog;
36          this.schema = schema;
37          this.tableName = tableName;
38          fullName = composeFullyQualifiedTableName(catalog,
39                  schema, tableName, '.');
40      }
41  
42      public String getCatalog() {
43          return catalog;
44      }
45  
46      public String getSchema() {
47          return schema;
48      }
49  
50      public String getTableName() {
51          return tableName;
52      }
53  
54      @Override
55      public boolean equals(Object obj) {
56          if (obj == null || !(obj instanceof ActualTableName)) {
57              return false;
58          }
59  
60          return obj.toString().equals(this.toString());
61      }
62  
63      @Override
64      public int hashCode() {
65          return fullName.hashCode();
66      }
67  
68      @Override
69      public String toString() {
70          return fullName;
71      }
72  }