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  /**
20   * <p>
21   * Definition of an interface for setting default values for specific configuration parameter objects.
22   * </p>
23   * <p>
24   * An object implementing this interface knows how to initialize a parameters object of a specific class with default
25   * values. Such objects can be registered at the {@link org.apache.commons.configuration2.builder.fluent.Parameters
26   * Parameters} class. Whenever a specific parameters object is created all registered {@code DefaultParametersHandler}
27   * objects that can handle this parameters type are invoked, so that they get the chance to perform arbitrary
28   * initialization.
29   * </p>
30   *
31   * @since 2.0
32   * @param <T> the type of parameters supported by this handler
33   */
34  public interface DefaultParametersHandler<T> {
35      /**
36       * Initializes the specified parameters object with default values. This method is called after the parameters object
37       * was created and before it is passed to the calling code. A concrete implementation can perform arbitrary
38       * initializations. Note that if there are multiple {@code DefaultParametersHandler} objects registered supporting this
39       * parameters type they are called in the order they have been registered. So handlers registered later can override
40       * initializations done by handlers registered earlier.
41       *
42       * @param parameters the parameters object to be initialized
43       */
44      void initializeDefaults(T parameters);
45  }