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    *     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  
19  import java.util.Map;
20  
21  /**
22   * <p>
23   * An interface to be implemented by objects which can be used to parameterize a {@link ConfigurationBuilder}.
24   * </p>
25   * <p>
26   * This interface is part of a Java DSL for creating and initializing builders for specific {@code Configuration}
27   * classes. Concrete implementations typically collect a set of related properties for the builder. There will be
28   * specific set methods for providing values for these properties. Then, this interface requires a generic
29   * {@code getParameters()} method which has to return all property values as a map. When constructing the builder the
30   * map is evaluated to define properties of the {@code Configuration} objects to be constructed.
31   * </p>
32   *
33   * @since 2.0
34   */
35  public interface BuilderParameters {
36      /**
37       * Constant for a prefix for reserved initialization parameter keys. If a parameter was set whose key starts with this
38       * prefix, it is filtered out before the initialization of a newly created result object. This mechanism allows
39       * implementing classes to store specific configuration data in the parameters map which does not represent a property
40       * value for the result object.
41       */
42      String RESERVED_PARAMETER_PREFIX = "config-";
43  
44      /**
45       * Gets a map with all parameters defined by this objects. The keys of the map correspond to concrete properties
46       * supported by the {@code Configuration} implementation class the builder produces. The values are the corresponding
47       * property values. The return value must not be <b>null</b>.
48       *
49       * @return a map with builder parameters
50       */
51      Map<String, Object> getParameters();
52  }