View Javadoc

1   /*
2    * Copyright 2010-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.testdoc.collect.extractor;
17  
18  import javax.lang.model.util.Elements;
19  
20  import org.apache.commons.lang.NullArgumentException;
21  
22  import de.smartics.testdoc.core.doc.names.TestNameUtils;
23  import de.smartics.testdoc.core.source.SourceCodeHelper;
24  
25  /**
26   * Contains helpers to access processing configuration.
27   *
28   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
29   * @version $Revision:591 $
30   */
31  public class ExtractorConfig
32  {
33    // ********************************* Fields *********************************
34  
35    // --- constants ------------------------------------------------------------
36  
37    // --- members --------------------------------------------------------------
38  
39    /**
40     * The utilities of the APT interface.
41     */
42    private final Elements elementUtils;
43  
44    /**
45     * The helper to access source code information.
46     */
47    private final SourceCodeHelper sourceCodeHelper;
48  
49    /**
50     * The utilities to create names to be displayed (as labels) for tests.
51     */
52    private final TestNameUtils testNameUtils;
53  
54    // ****************************** Initializer *******************************
55  
56    // ****************************** Constructors ******************************
57  
58    /**
59     * Default constructor.
60     *
61     * @param elementUtils the utilities of the APT interface.
62     * @param sourceCodeHelper the helper to access source code information.
63     * @param testNameUtils the utilities to create names to be displayed (as
64     *          labels) for tests.
65     * @throws NullArgumentException if any argument is <code>null</code>.
66     */
67    public ExtractorConfig(final Elements elementUtils,
68        final SourceCodeHelper sourceCodeHelper,
69        final TestNameUtils testNameUtils)
70      throws NullArgumentException
71    {
72      checkArguments(elementUtils, sourceCodeHelper, testNameUtils);
73      this.elementUtils = elementUtils;
74      this.sourceCodeHelper = sourceCodeHelper;
75      this.testNameUtils = testNameUtils;
76    }
77  
78    private void checkArguments(final Elements elementUtils,
79        final SourceCodeHelper sourceCodeHelper,
80        final TestNameUtils testNameUtils)
81    {
82      if (elementUtils == null)
83      {
84        throw new NullArgumentException("elementUtils");
85      }
86      if (sourceCodeHelper == null)
87      {
88        throw new NullArgumentException("sourceCodeHelper");
89      }
90      if (testNameUtils == null)
91      {
92        throw new NullArgumentException("testNameUtils");
93      }
94    }
95  
96    // ****************************** Inner Classes *****************************
97  
98    // ********************************* Methods ********************************
99  
100   // --- init -----------------------------------------------------------------
101 
102   // --- get&set --------------------------------------------------------------
103 
104   /**
105    * Returns the utilities of the APT interface.
106    *
107    * @return the utilities of the APT interface.
108    */
109   public Elements getElementUtils()
110   {
111     return elementUtils;
112   }
113 
114   /**
115    * Returns the helper to access source code information.
116    *
117    * @return the helper to access source code information.
118    */
119   public SourceCodeHelper getSourceCodeHelper()
120   {
121     return sourceCodeHelper;
122   }
123 
124   /**
125    * Returns the utilities to create names to be displayed (as labels) for
126    * tests.
127    *
128    * @return the utilities to create names to be displayed (as labels) for
129    *         tests.
130    */
131   public TestNameUtils getTestNameUtils()
132   {
133     return testNameUtils;
134   }
135 
136   // --- business -------------------------------------------------------------
137 
138   // --- object basics --------------------------------------------------------
139 
140 }