1 package org.apache.maven.tools.plugin.javadoc;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.Map;
23
24 import org.apache.maven.tools.plugin.extractor.javadoc.JavadocMojoAnnotation;
25
26 import com.sun.tools.doclets.Taglet;
27
28 // CHECKSTYLE_OFF: LineLength
29 /**
30 * The <tt>@parameter</tt> tag is used to define a Mojo parameter and has annotation parameter.
31 * <br/>
32 * The following is a sample declaration:
33 * <pre>
34 * public class MyMojo extends AbstractMojo
35 * {
36 * /**
37 *  * Dummy parameter.
38 *  *
39 *  * @parameter <name="..."> <alias="..."> <default-value="..."> <expression="...">
40 *  * <implementation="..."> <property="...">
41 *  * ...
42 *  */
43 * private Object parameterName;
44 * }
45 * </pre>
46 * To use it, calling the <code>Javadoc</code> tool with the following:
47 * <pre>
48 * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet'
49 * </pre>
50 *
51 * @see <a href="package-summary.html#package_description">package-summary.html</a>
52 *
53 * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
54 * @version $Id: MojoParameterFieldTaglet.html 1024032 2018-01-19 18:16:30Z hboutemy $
55 */
56 //CHECKSTYLE_ON: LineLength
57 public class MojoParameterFieldTaglet
58 extends AbstractMojoFieldTaglet
59 {
60 /** The Javadoc annotation */
61 private static final String NAME = JavadocMojoAnnotation.PARAMETER;
62
63 private static final String[] PARAMETERS_NAME = {
64 JavadocMojoAnnotation.PARAMETER_NAME,
65 JavadocMojoAnnotation.PARAMETER_ALIAS,
66 JavadocMojoAnnotation.PARAMETER_DEFAULT_VALUE,
67 JavadocMojoAnnotation.PARAMETER_EXPRESSION,
68 JavadocMojoAnnotation.PARAMETER_IMPLEMENTATION,
69 JavadocMojoAnnotation.PARAMETER_PROPERTY };
70
71 /** The Javadoc text which will be added to the generated page. */
72 protected static final String HEADER = "Is defined by";
73
74 /**
75 * @return By default, return the string defined in {@linkplain #HEADER}.
76 * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getHeader()
77 * @see #HEADER
78 */
79 public String getHeader()
80 {
81 return HEADER;
82 }
83
84 /**
85 * @return <code>null</code> since <code>@parameter</code> has no value.
86 * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedValue()
87 */
88 public String getAllowedValue()
89 {
90 return null;
91 }
92
93 /**
94 * @return <code>MojoParameterFieldTaglet#PARAMETERS_NAME</code> since <code>@parameter</code> has parameters.
95 * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedParameterNames()
96 */
97 public String[] getAllowedParameterNames()
98 {
99 return PARAMETERS_NAME;
100 }
101
102 /**
103 * @return By default, return the name of this taglet.
104 * @see com.sun.tools.doclets.Taglet#getName()
105 * @see MojoParameterFieldTaglet#NAME
106 */
107 public String getName()
108 {
109 return NAME;
110 }
111
112 /**
113 * Register this Taglet.
114 *
115 * @param tagletMap the map to register this tag to.
116 */
117 public static void register( Map<String, Taglet> tagletMap )
118 {
119 MojoParameterFieldTaglet tag = new MojoParameterFieldTaglet();
120 Taglet t = tagletMap.get( tag.getName() );
121 if ( t != null )
122 {
123 tagletMap.remove( tag.getName() );
124 }
125 tagletMap.put( tag.getName(), tag );
126 }
127 }