    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 java.util.Map;
    020
    021/**
    022 * <p>
    023 * A specialized parameters class for INI configuration.
    024 * </p>
    025 * <p>
    026 * This parameters class defines some properties which allow customizing the parsing and writing of INI documents.
    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.2
    034 */
    035public class INIBuilderParametersImpl extends HierarchicalBuilderParametersImpl implements INIBuilderProperties<INIBuilderParametersImpl> {
    036
    037    /** The key for the separatorUsedInINIOutput property. */
    038    private static final String PROP_SEPARATOR_USED_IN_INI_OUTPUT = "separatorUsedInOutput";
    039
    040    /** The key for the separatorUsedInInput property. */
    041    private static final String PROP_SEPARATOR_USED_IN_INI_INPUT = "separatorUsedInInput";
    042
    043    /** The key for the commentLeadingCharsUsedInInput property. */
    044    private static final String PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT = "commentLeadingCharsUsedInInput";
    045
    046    /**
    047     * Constructs a new instance.
    048     */
    049    public INIBuilderParametersImpl() {
    050        // empty
    051    }
    052
    053    @Override
    054    public void inheritFrom(final Map<String, ?> source) {
    055        super.inheritFrom(source);
    056        copyPropertiesFrom(source, PROP_SEPARATOR_USED_IN_INI_OUTPUT);
    057        copyPropertiesFrom(source, PROP_SEPARATOR_USED_IN_INI_INPUT);
    058        copyPropertiesFrom(source, PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT);
    059    }
    060
    061    @Override
    062    public INIBuilderParametersImpl setCommentLeadingCharsUsedInInput(final String separator) {
    063        storeProperty(PROP_COMMENT_LEADING_SEPARATOR_USED_IN_INI_INPUT, separator);
    064        return this;
    065    }
    066
    067    @Override
    068    public INIBuilderParametersImpl setSeparatorUsedInInput(final String separator) {
    069        storeProperty(PROP_SEPARATOR_USED_IN_INI_INPUT, separator);
    070        return this;
    071    }
    072
    073    @Override
    074    public INIBuilderParametersImpl setSeparatorUsedInOutput(final String separator) {
    075        storeProperty(PROP_SEPARATOR_USED_IN_INI_OUTPUT, separator);
    076        return this;
    077    }
    078}