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.ImmutableConfiguration;
20 import org.apache.commons.configuration2.event.EventSource;
21 import org.apache.commons.configuration2.ex.ConfigurationException;
22
23 /**
24 * <p>
25 * Definition of an interface for objects that can create {@link ImmutableConfiguration} or
26 * {@link org.apache.commons.configuration2.Configuration Configuration} objects of a specific type.
27 * </p>
28 * <p>
29 * This interface defines an abstract way of creating a {@code ImmutableConfiguration} object. It does not assume any
30 * specific way of how this is done; this is completely in the responsibility of an implementation class. There is just
31 * a single method that returns the configuration constructed by this builder.
32 * </p>
33 * <p>
34 * Note: {@code ImmutableConfiguration} is just the base interface for all configuration objects. So that the return
35 * type of the {@code getConfiguration()} method is {@code ImmutableConfiguration} does not mean that only immutable
36 * configurations can be created.
37 * </p>
38 *
39 * @param <T> the concrete type of the {@code ImmutableConfiguration} class produced by this builder
40 * @since 2.0
41 */
42 public interface ConfigurationBuilder<T extends ImmutableConfiguration> extends EventSource {
43
44 /**
45 * Gets the configuration provided by this builder. An implementation has to perform all necessary steps for creating
46 * and initializing a {@code ImmutableConfiguration} object.
47 *
48 * @return the configuration
49 * @throws ConfigurationException if an error occurs
50 */
51 T getConfiguration() throws ConfigurationException;
52 }