001package org.apache.maven.tools.plugin.javadoc;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.util.Map;
023
024import org.apache.maven.tools.plugin.extractor.javadoc.JavadocMojoAnnotation;
025
026import com.sun.tools.doclets.Taglet;
027
028/**
029 * The <tt>@readonly</tt> tag is used to specify that this parameter cannot be configured directly by the
030 * user and has no parameter.
031 * <br/>
032 * The following is a sample declaration:
033 * <pre>
034 * public class MyMojo extends AbstractMojo
035 * {
036 *   &#x2f;&#x2a;&#x2a;
037 *   &#x20;&#x2a; Dummy parameter.
038 *   &#x20;&#x2a;
039 *   &#x20;&#x2a; &#64;readonly
040 *   &#x20;&#x2a; ...
041 *   &#x20;&#x2a;&#x2f;
042 *   private Object parameterName;
043 * }
044 * </pre>
045 * To use it, calling the <code>Javadoc</code> tool with the following:
046 * <pre>
047 * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet'
048 * </pre>
049 * <b>Note</b>: This taglet is similar to call the <code>Javadoc</code> tool with the following:
050 * <pre>
051 * javadoc ... -tag 'readonly:f:Is readonly.'
052 * </pre>
053 *
054 * @see <a href="package-summary.html#package_description">package-summary.html</a>
055 *
056 * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
057 * @version $Id: MojoReadOnlyFieldTaglet.html 1030109 2018-05-20 14:45:18Z hboutemy $
058 */
059public class MojoReadOnlyFieldTaglet
060    extends AbstractMojoFieldTaglet
061{
062    /** The Javadoc annotation */
063    private static final String NAME = JavadocMojoAnnotation.READONLY;
064
065    /** The Javadoc text which will be added to the generated page. */
066    protected static final String HEADER = "Is readonly.";
067
068    /**
069     * @return By default, return the string defined in {@linkplain #HEADER}.
070     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getHeader()
071     * @see #HEADER
072     */
073    public String getHeader()
074    {
075        return HEADER;
076    }
077
078    /**
079     * @return <code>null</code> since <code>@readonly</code> has no value.
080     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedValue()
081     */
082    public String getAllowedValue()
083    {
084        return null;
085    }
086
087    /**
088     * @return <code>null</code> since <code>@readonly</code> has no parameter.
089     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedParameterNames()
090     */
091    public String[] getAllowedParameterNames()
092    {
093        return null;
094    }
095
096    /**
097     * @return By default, return the name of this taglet.
098     * @see com.sun.tools.doclets.Taglet#getName()
099     * @see MojoReadOnlyFieldTaglet#NAME
100     */
101    public String getName()
102    {
103        return NAME;
104    }
105
106    /**
107     * Register this Taglet.
108     *
109     * @param tagletMap the map to register this tag to.
110     */
111    public static void register( Map<String, Taglet> tagletMap )
112    {
113        MojoReadOnlyFieldTaglet tag = new MojoReadOnlyFieldTaglet();
114        Taglet t = tagletMap.get( tag.getName() );
115        if ( t != null )
116        {
117            tagletMap.remove( tag.getName() );
118        }
119        tagletMap.put( tag.getName(), tag );
120    }
121}