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.api;
17
18 import java.util.List;
19 import java.util.Properties;
20
21 import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
22 import org.mybatis.generator.config.Context;
23
24 /**
25 * This interface describes methods that are required in any Java type resolver.
26 * A Java type resolver is used to make a default translation between a JDBC
27 * type as returned from the database introspection process, and a Java type.
28 *
29 * @author Jeff Butler
30 */
31 public interface JavaTypeResolver {
32 /**
33 * Adds properties for this instance from any properties configured in the
34 * JavaTypeResolverConfiguration.
35 *
36 * This method will be called before any of the get methods.
37 *
38 * @param properties
39 * All properties from the configuration
40 */
41 void addConfigurationProperties(Properties properties);
42
43 /**
44 * Sets the instance of the Context object associated with this instance.
45 *
46 * This method will be called before any of the get methods.
47 *
48 * @param context
49 * The current Context
50 */
51 void setContext(Context context);
52
53 /**
54 * The generator will supply a list to this method. The implementation class may add strings to the list that will
55 * be treated as warning messages and displayed to the user. The concept of a warning is that code generation can
56 * continue, but that the results may not be what is expected.
57 *
58 * @param warnings
59 * the new warnings
60 */
61 void setWarnings(List<String> warnings);
62
63 /**
64 * Calculates and returns the Java type that should be associated with this
65 * column based on the jdbc type, length, and scale of the column.
66 *
67 * @param introspectedColumn
68 * the column whose Java type needs to be calculated
69 * @return the calculated type, or null if an unsupported data type. If null
70 * is returned, we will set the type to Object and issue a
71 * warning unless the column is ignored or otherwise overridden
72 */
73 FullyQualifiedJavaType calculateJavaType(
74 IntrospectedColumn introspectedColumn);
75
76 /**
77 * Calculates and returns the JDBC type name that should be associated with
78 * this column based on the jdbc type, length, and scale of the column.
79 *
80 * @param introspectedColumn
81 * the column whose Java type needs to be calculated
82 * @return the calculated type name, or null if an unsupported data type. If
83 * null is returned, we will set the type to OTHER and issue a
84 * warning unless the column is ignored or otherwise overridden
85 */
86 String calculateJdbcTypeName(IntrospectedColumn introspectedColumn);
87 }