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 * Sets the current include listener, may be null.
43 *
44 * @param includeListener the current include listener, may be null.
45 * @return a reference to this object for method chaining
46 * @since 2.6
47 */
48 default T setIncludeListener(final ConfigurationConsumer<ConfigurationException> includeListener) {
49 return (T) this;
50 }
51
52 /**
53 * Sets a flag whether include files are supported by the properties configuration object. If set to <strong>true</strong>, files
54 * listed by an include property are loaded automatically.
55 *
56 * @param f the value of the flag
57 * @return a reference to this object for method chaining
58 */
59 T setIncludesAllowed(boolean f);
60
61 /**
62 * Sets the {@code IOFactory} to be used by the properties configuration object. With this method a custom factory for
63 * input and output streams can be set. This allows customizing the format of properties read or written by the
64 * configuration. If no {@code IOFactory} is provided, the configuration uses a default one.
65 *
66 * @param factory the {@code IOFactory} to be used by the configuration
67 * @return a reference to this object for method chaining
68 */
69 T setIOFactory(IOFactory factory);
70
71 /**
72 * Sets the layout object for the properties configuration object. With this method a custom layout object can be set.
73 * If no layout is provided, the configuration will use a default layout.
74 *
75 * @param layout the {@code PropertiesConfigurationLayout} object to be used by the configuration
76 * @return a reference to this object for method chaining
77 */
78 T setLayout(PropertiesConfigurationLayout layout);
79 }