View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.rat;
20  
21  import java.lang.reflect.Method;
22  import java.util.Map;
23  import java.util.SortedSet;
24  
25  import org.apache.rat.analysis.IHeaderMatcher;
26  import org.apache.rat.license.ILicenseFamily;
27  
28  /**
29   * Parameters that can be set by the BUILDER_PARAM ComponentType. The name of the method listed here
30   * should be the same as the name specified in the ConfigComponent.
31   */
32  public interface BuilderParams {
33      /**
34       * Gets one of the contained methods by name.
35       *
36       * @param name the name of the method to get.
37       * @return the Method.
38       */
39      default Method get(String name) {
40          try {
41              return this.getClass().getMethod(name);
42          } catch (NoSuchMethodException e) {
43              throw new ImplementationException(String.format("method '%s' is not found in %s", name, this.getClass()));
44          } catch (IllegalArgumentException e) {
45              throw new ImplementationException(
46                      String.format("method '%s' in %s can not be retrieved", name, this.getClass()), e);
47          }
48      }
49  
50      /**
51       * Gets a mapping of matcher names to matchers.
52       *
53       * @return the mapping of matcher names to matchers.
54       */
55      Map<String, IHeaderMatcher> matcherMap();
56      // the above method is called by reflection.
57  
58      /**
59       * Gets a sorted set of registered license families.
60       *
61       * @return the sorted set of license families.
62       */
63      SortedSet<ILicenseFamily> licenseFamilies();
64      // the above method is called  by reflection
65  }