    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *     https://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.configuration2.builder;
    018
    019import javax.sql.DataSource;
    020
    021/**
    022 * <p>
    023 * A specialized parameters object for database configurations.
    024 * </p>
    025 * <p>
    026 * This class has properties for defining the database structures the configuration operates on.
    027 * </p>
    028 * <p>
    029 * This class is not thread-safe. It is intended that an instance is constructed and initialized by a single thread
    030 * during configuration of a {@code ConfigurationBuilder}.
    031 * </p>
    032 *
    033 * @since 2.0
    034 */
    035public class DatabaseBuilderParametersImpl extends BasicBuilderParameters implements DatabaseBuilderProperties<DatabaseBuilderParametersImpl> {
    036
    037    /** Constant for the data source property. */
    038    private static final String PROP_DATA_SOURCE = "dataSource";
    039
    040    /** Constant for the table property. */
    041    private static final String PROP_TABLE = "table";
    042
    043    /** Constant for the key column property. */
    044    private static final String PROP_KEY_COLUMN = "keyColumn";
    045
    046    /** Constant for the value column property. */
    047    private static final String PROP_VALUE_COLUMN = "valueColumn";
    048
    049    /** Constant for the configuration name column property. */
    050    private static final String PROP_CONFIG_NAME_COLUMN = "configurationNameColumn";
    051
    052    /** Constant for the configuration name property. */
    053    private static final String PROP_CONFIG_NAME = "configurationName";
    054
    055    /** Constant for the auto commit property. */
    056    private static final String PROP_AUTO_COMMIT = "autoCommit";
    057
    058    /**
    059     * Constructs a new instance.
    060     */
    061    public DatabaseBuilderParametersImpl() {
    062        // empty
    063    }
    064
    065    @Override
    066    public DatabaseBuilderParametersImpl setAutoCommit(final boolean f) {
    067        storeProperty(PROP_AUTO_COMMIT, Boolean.valueOf(f));
    068        return this;
    069    }
    070
    071    @Override
    072    public DatabaseBuilderParametersImpl setConfigurationName(final String name) {
    073        storeProperty(PROP_CONFIG_NAME, name);
    074        return this;
    075    }
    076
    077    @Override
    078    public DatabaseBuilderParametersImpl setConfigurationNameColumn(final String name) {
    079        storeProperty(PROP_CONFIG_NAME_COLUMN, name);
    080        return this;
    081    }
    082
    083    @Override
    084    public DatabaseBuilderParametersImpl setDataSource(final DataSource src) {
    085        storeProperty(PROP_DATA_SOURCE, src);
    086        return this;
    087    }
    088
    089    @Override
    090    public DatabaseBuilderParametersImpl setKeyColumn(final String name) {
    091        storeProperty(PROP_KEY_COLUMN, name);
    092        return this;
    093    }
    094
    095    @Override
    096    public DatabaseBuilderParametersImpl setTable(final String tableName) {
    097        storeProperty(PROP_TABLE, tableName);
    098        return this;
    099    }
    100
    101    @Override
    102    public DatabaseBuilderParametersImpl setValueColumn(final String name) {
    103        storeProperty(PROP_VALUE_COLUMN, name);
    104        return this;
    105    }
    106}