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 org.apache.commons.configuration2.ConfigurationConsumer;
20  import org.apache.commons.configuration2.PropertiesConfiguration.IOFactory;
21  import org.apache.commons.configuration2.PropertiesConfigurationLayout;
22  import org.apache.commons.configuration2.ex.ConfigurationException;
23  
24  /**
25   * <p>
26   * Definition of a parameters interface for properties configurations.
27   * </p>
28   * <p>
29   * This interface defines additional properties which can be set when initializing a {@code PropertiesConfiguration}
30   * object.
31   * </p>
32   * <p>
33   * <strong>Important note:</strong> This interface is not intended to be implemented by client code! It defines a set of
34   * available properties and may be extended even in minor releases.
35   * </p>
36   *
37   * @param <T> the type of the result of all set methods for method chaining
38   * @since 2.0
39   */
40  public interface PropertiesBuilderProperties<T> {
41  
42      /**
43       * Sets the current include listener, may be null.
44       *
45       * @param includeListener the current include listener, may be null.
46       * @return a reference to this object for method chaining
47       * @since 2.6
48       */
49      default T setIncludeListener(final ConfigurationConsumer<ConfigurationException> includeListener) {
50          return (T) this;
51      }
52  
53      /**
54       * Sets a flag whether include files are supported by the properties configuration object. If set to <strong>true</strong>, files
55       * listed by an include property are loaded automatically.
56       *
57       * @param f the value of the flag
58       * @return a reference to this object for method chaining
59       */
60      T setIncludesAllowed(boolean f);
61  
62      /**
63       * Sets the {@code IOFactory} to be used by the properties configuration object. With this method a custom factory for
64       * input and output streams can be set. This allows customizing the format of properties read or written by the
65       * configuration. If no {@code IOFactory} is provided, the configuration uses a default one.
66       *
67       * @param factory the {@code IOFactory} to be used by the configuration
68       * @return a reference to this object for method chaining
69       */
70      T setIOFactory(IOFactory factory);
71  
72      /**
73       * Sets the layout object for the properties configuration object. With this method a custom layout object can be set.
74       * If no layout is provided, the configuration will use a default layout.
75       *
76       * @param layout the {@code PropertiesConfigurationLayout} object to be used by the configuration
77       * @return a reference to this object for method chaining
78       */
79      T setLayout(PropertiesConfigurationLayout layout);
80  }