View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.configuration2.builder;
18  
19  import javax.sql.DataSource;
20  
21  /**
22   * <p>
23   * A specialized parameters object for database configurations.
24   * </p>
25   * <p>
26   * This class has properties for defining the database structures the configuration operates on.
27   * </p>
28   * <p>
29   * This class is not thread-safe. It is intended that an instance is constructed and initialized by a single thread
30   * during configuration of a {@code ConfigurationBuilder}.
31   * </p>
32   *
33   * @since 2.0
34   */
35  public class DatabaseBuilderParametersImpl extends BasicBuilderParameters implements DatabaseBuilderProperties<DatabaseBuilderParametersImpl> {
36      /** Constant for the data source property. */
37      private static final String PROP_DATA_SOURCE = "dataSource";
38  
39      /** Constant for the table property. */
40      private static final String PROP_TABLE = "table";
41  
42      /** Constant for the key column property. */
43      private static final String PROP_KEY_COLUMN = "keyColumn";
44  
45      /** Constant for the value column property. */
46      private static final String PROP_VALUE_COLUMN = "valueColumn";
47  
48      /** Constant for the configuration name column property. */
49      private static final String PROP_CONFIG_NAME_COLUMN = "configurationNameColumn";
50  
51      /** Constant for the configuration name property. */
52      private static final String PROP_CONFIG_NAME = "configurationName";
53  
54      /** Constant for the auto commit property. */
55      private static final String PROP_AUTO_COMMIT = "autoCommit";
56  
57      /**
58       * Constructs a new instance.
59       */
60      public DatabaseBuilderParametersImpl() {
61          // empty
62      }
63  
64      @Override
65      public DatabaseBuilderParametersImpl setAutoCommit(final boolean f) {
66          storeProperty(PROP_AUTO_COMMIT, Boolean.valueOf(f));
67          return this;
68      }
69  
70      @Override
71      public DatabaseBuilderParametersImpl setConfigurationName(final String name) {
72          storeProperty(PROP_CONFIG_NAME, name);
73          return this;
74      }
75  
76      @Override
77      public DatabaseBuilderParametersImpl setConfigurationNameColumn(final String name) {
78          storeProperty(PROP_CONFIG_NAME_COLUMN, name);
79          return this;
80      }
81  
82      @Override
83      public DatabaseBuilderParametersImpl setDataSource(final DataSource src) {
84          storeProperty(PROP_DATA_SOURCE, src);
85          return this;
86      }
87  
88      @Override
89      public DatabaseBuilderParametersImpl setKeyColumn(final String name) {
90          storeProperty(PROP_KEY_COLUMN, name);
91          return this;
92      }
93  
94      @Override
95      public DatabaseBuilderParametersImpl setTable(final String tableName) {
96          storeProperty(PROP_TABLE, tableName);
97          return this;
98      }
99  
100     @Override
101     public DatabaseBuilderParametersImpl setValueColumn(final String name) {
102         storeProperty(PROP_VALUE_COLUMN, name);
103         return this;
104     }
105 }