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.core;
17  
18  import static de.smartics.properties.core.PropertyEnumerationInfo.create;
19  import de.smartics.properties.core.PropertyEnumeration;
20  import de.smartics.properties.core.PropertyEnumerationInfo;
21  import de.smartics.properties.core.PropertyValueRange;
22  
23  /**
24   * Provides properties for the configuration of the test doc report.
25   *
26   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
27   * @version $Revision:591 $
28   */
29  public enum TestDocProperty implements PropertyEnumeration
30  {
31    // ****************************** Enumeration *******************************
32  
33    /**
34     * The name of a class that implements
35     * {@link de.smartics.testdoc.report.doc.TestNameUtils} to handle names found
36     * in test cases.
37     * <p>
38     * The implementation is required to provide a public no-args constructor.
39     * </p>
40     */
41    TEST_NAME_UTILS_CLASS_NAME(create("test-doc", "tdoc.testNameUtils",
42        String.class)),
43  
44    /**
45     * The name of a class that implements
46     * {@link de.smartics.testdoc.report.ExportAdapter} to handle unit test
47     * documentation found by the annotation processor.
48     * <p>
49     * The implementation is required to provide a public no-args constructor.
50     * </p>
51     */
52    EXPORT_ADAPTER_CLASS_NAME(create("test-doc", "tdoc.exporter", String.class)),
53  
54    /**
55     * The path to the directory to export the test documentation fragments to.
56     * <p>
57     * This will neglect the {@link #EXPORT_ADAPTER_CLASS_NAME} property and
58     * select a directory based export adapter.
59     * </p>
60     */
61    EXPORT_ADAPTER_BASE_DIR(create("test-doc", "tdoc.exporter.baseDir",
62        String.class)),
63  
64    /**
65     * Allows to control the verboseness of the processor.
66     * <p>
67     * If <code>tdoc.processor.quiet</code> is set to <code>true</code>, the
68     * processor will be less verbose.
69     * </p>
70     */
71    PROC_CONF_QUIET(create("test-doc", "tdoc.processor.quiet", Boolean.class,
72        Boolean.FALSE));
73  
74    // ********************************* Fields *********************************
75  
76    /**
77     * The delegate holding the property information.
78     */
79    private final PropertyEnumerationInfo info;
80  
81    // ****************************** Constructors ******************************
82  
83    /**
84     * Default constructor.
85     *
86     * @param info the delegate holding the property information.
87     * @throws NullPointerException if either name or type is <code>null</code>.
88     */
89    private TestDocProperty(final PropertyEnumerationInfo info)
90      throws NullPointerException
91    {
92      this.info = info;
93    }
94  
95    // ********************************* Methods ********************************
96  
97    // --- init -----------------------------------------------------------------
98  
99    // --- get&set --------------------------------------------------------------
100 
101   /**
102    * {@inheritDoc}
103    *
104    * @see de.smartics.properties.core.PropertyEnumeration#getComponentName()
105    */
106   @Override
107   public String getComponentName()
108   {
109     return info.getComponentName();
110   }
111 
112   /**
113    * Returns the property name.
114    *
115    * @return the property name.
116    */
117   public String getName()
118   {
119     return info.getName();
120   }
121 
122   /**
123    * {@inheritDoc}
124    *
125    * @see de.smartics.properties.core.PropertyEnumeration#getType()
126    */
127   public Class<?> getType()
128   {
129     return info.getType();
130   }
131 
132   /**
133    * {@inheritDoc}
134    *
135    * @see de.smartics.properties.core.PropertyEnumeration#isMandatory()
136    */
137   public boolean isMandatory()
138   {
139     return info.isMandatory();
140   }
141 
142   /**
143    * Returns the default value to use if a given property is not specified. May
144    * be <code>null</code> if no default value is provided.
145    *
146    * @return the default value to use if a given property is not specified.
147    */
148   public Object getDefaultValue()
149   {
150     return info.getDefaultValue();
151   }
152 
153   /**
154    * {@inheritDoc}
155    *
156    * @see de.smartics.properties.core.PropertyEnumeration#getValueRange()
157    */
158   public PropertyValueRange<?> getValueRange()
159   {
160     return info.getValueRange();
161   }
162 
163   // --- business -------------------------------------------------------------
164 
165   // --- object basics --------------------------------------------------------
166 
167   /**
168    * Returns the string representation of the object.
169    *
170    * @return the string representation of the object.
171    */
172   @Override
173   public String toString()
174   {
175     return getName();
176   }
177 }