PropertiesBuilderProperties.java

  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.  *     http://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. import org.apache.commons.configuration2.ConfigurationConsumer;
  19. import org.apache.commons.configuration2.PropertiesConfiguration.IOFactory;
  20. import org.apache.commons.configuration2.PropertiesConfigurationLayout;
  21. import org.apache.commons.configuration2.ex.ConfigurationException;

  22. /**
  23.  * <p>
  24.  * Definition of a parameters interface for properties configurations.
  25.  * </p>
  26.  * <p>
  27.  * This interface defines additional properties which can be set when initializing a {@code PropertiesConfiguration}
  28.  * object.
  29.  * </p>
  30.  * <p>
  31.  * <strong>Important note:</strong> This interface is not intended to be implemented by client code! It defines a set of
  32.  * available properties and may be extended even in minor releases.
  33.  * </p>
  34.  *
  35.  * @param <T> the type of the result of all set methods for method chaining
  36.  * @since 2.0
  37.  */
  38. public interface PropertiesBuilderProperties<T> {
  39.     /**
  40.      * Sets the current include listener, may be null.
  41.      *
  42.      * @param includeListener the current include listener, may be null.
  43.      * @return a reference to this object for method chaining
  44.      * @since 2.6
  45.      */
  46.     default T setIncludeListener(final ConfigurationConsumer<ConfigurationException> includeListener) {
  47.         return (T) this;
  48.     }

  49.     /**
  50.      * Sets a flag whether include files are supported by the properties configuration object. If set to <strong>true</strong>, files
  51.      * listed by an include property are loaded automatically.
  52.      *
  53.      * @param f the value of the flag
  54.      * @return a reference to this object for method chaining
  55.      */
  56.     T setIncludesAllowed(boolean f);

  57.     /**
  58.      * Sets the {@code IOFactory} to be used by the properties configuration object. With this method a custom factory for
  59.      * input and output streams can be set. This allows customizing the format of properties read or written by the
  60.      * configuration. If no {@code IOFactory} is provided, the configuration uses a default one.
  61.      *
  62.      * @param factory the {@code IOFactory} to be used by the configuration
  63.      * @return a reference to this object for method chaining
  64.      */
  65.     T setIOFactory(IOFactory factory);

  66.     /**
  67.      * Sets the layout object for the properties configuration object. With this method a custom layout object can be set.
  68.      * If no layout is provided, the configuration will use a default layout.
  69.      *
  70.      * @param layout the {@code PropertiesConfigurationLayout} object to be used by the configuration
  71.      * @return a reference to this object for method chaining
  72.      */
  73.     T setLayout(PropertiesConfigurationLayout layout);
  74. }