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.messages.Messages.getString;
19  
20  import java.util.List;
21  
22  import org.mybatis.generator.internal.util.StringUtility;
23  
24  public class ConnectionFactoryConfiguration extends TypedPropertyHolder {
25  
26      public ConnectionFactoryConfiguration() {
27          super();
28      }
29  
30      public void validate(List<String> errors) {
31          if (getConfigurationType() == null || "DEFAULT".equals(getConfigurationType())) { //$NON-NLS-1$
32              if (!StringUtility.stringHasValue(getProperty("driverClass"))) { //$NON-NLS-1$
33                  errors.add(getString("ValidationError.18", //$NON-NLS-1$
34                          "connectionFactory", //$NON-NLS-1$
35                          "driverClass")); //$NON-NLS-1$
36              }
37  
38              if (!StringUtility.stringHasValue(getProperty("connectionURL"))) { //$NON-NLS-1$
39                  errors.add(getString("ValidationError.18", //$NON-NLS-1$
40                          "connectionFactory", //$NON-NLS-1$
41                          "connectionURL")); //$NON-NLS-1$
42              }
43          }
44      }
45  }