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.config;
17  
18  import static org.mybatis.generator.internal.util.StringUtility.stringContainsSpace;
19  import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
20  import static org.mybatis.generator.internal.util.messages.Messages.getString;
21  
22  import java.util.List;
23  
24  public class ColumnOverride extends PropertyHolder {
25  
26      private final String columnName;
27  
28      private String javaProperty;
29  
30      private String jdbcType;
31  
32      private String javaType;
33  
34      private String typeHandler;
35  
36      private boolean isColumnNameDelimited;
37  
38      /**
39       * If true, the column is a GENERATED ALWAYS column which means
40       * that it should not be used in insert or update statements.
41       */
42      private boolean isGeneratedAlways;
43  
44      public ColumnOverride(String columnName) {
45          super();
46  
47          this.columnName = columnName;
48          isColumnNameDelimited = stringContainsSpace(columnName);
49      }
50  
51      public String getColumnName() {
52          return columnName;
53      }
54  
55      public String getJavaProperty() {
56          return javaProperty;
57      }
58  
59      public void setJavaProperty(String javaProperty) {
60          this.javaProperty = javaProperty;
61      }
62  
63      public String getJavaType() {
64          return javaType;
65      }
66  
67      public void setJavaType(String javaType) {
68          this.javaType = javaType;
69      }
70  
71      public String getJdbcType() {
72          return jdbcType;
73      }
74  
75      public void setJdbcType(String jdbcType) {
76          this.jdbcType = jdbcType;
77      }
78  
79      public String getTypeHandler() {
80          return typeHandler;
81      }
82  
83      public void setTypeHandler(String typeHandler) {
84          this.typeHandler = typeHandler;
85      }
86  
87      public boolean isColumnNameDelimited() {
88          return isColumnNameDelimited;
89      }
90  
91      public void setColumnNameDelimited(boolean isColumnNameDelimited) {
92          this.isColumnNameDelimited = isColumnNameDelimited;
93      }
94  
95      public void validate(List<String> errors, String tableName) {
96          if (!stringHasValue(columnName)) {
97              errors.add(getString("ValidationError.22", //$NON-NLS-1$
98                      tableName));
99          }
100     }
101 
102     public boolean isGeneratedAlways() {
103         return isGeneratedAlways;
104     }
105 
106     public void setGeneratedAlways(boolean isGeneratedAlways) {
107         this.isGeneratedAlways = isGeneratedAlways;
108     }
109 }