Coverage Report - com.puppycrawl.tools.checkstyle.api.JavadocTagInfo
 
Classes in this File Line Coverage Branch Coverage Complexity
JavadocTagInfo
77%
42/54
25%
2/8
4.533
JavadocTagInfo$1
33%
1/3
0%
0/10
4.533
JavadocTagInfo$10
33%
1/3
0%
0/8
4.533
JavadocTagInfo$11
25%
1/4
0%
0/4
4.533
JavadocTagInfo$12
33%
1/3
0%
0/18
4.533
JavadocTagInfo$13
33%
1/3
0%
0/4
4.533
JavadocTagInfo$14
20%
1/5
0%
0/14
4.533
JavadocTagInfo$15
25%
1/4
0%
0/6
4.533
JavadocTagInfo$16
33%
1/3
0%
0/18
4.533
JavadocTagInfo$17
33%
1/3
0%
0/4
4.533
JavadocTagInfo$18
33%
1/3
0%
0/18
4.533
JavadocTagInfo$19
33%
1/3
0%
0/10
4.533
JavadocTagInfo$2
33%
1/3
0%
0/18
4.533
JavadocTagInfo$3
33%
1/3
0%
0/18
4.533
JavadocTagInfo$4
33%
1/3
0%
0/20
4.533
JavadocTagInfo$5
33%
1/3
0%
0/4
4.533
JavadocTagInfo$6
100%
3/3
100%
6/6
4.533
JavadocTagInfo$7
33%
1/3
0%
0/18
4.533
JavadocTagInfo$8
33%
1/3
0%
0/18
4.533
JavadocTagInfo$9
33%
1/3
0%
0/18
4.533
JavadocTagInfo$Type
100%
3/3
N/A
4.533
 
 1  
 ////////////////////////////////////////////////////////////////////////////////
 2  
 // checkstyle: Checks Java source code for adherence to a set of rules.
 3  
 // Copyright (C) 2001-2014  Oliver Burn
 4  
 //
 5  
 // This library is free software; you can redistribute it and/or
 6  
 // modify it under the terms of the GNU Lesser General Public
 7  
 // License as published by the Free Software Foundation; either
 8  
 // version 2.1 of the License, or (at your option) any later version.
 9  
 //
 10  
 // This library is distributed in the hope that it will be useful,
 11  
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
 // Lesser General Public License for more details.
 14  
 //
 15  
 // You should have received a copy of the GNU Lesser General Public
 16  
 // License along with this library; if not, write to the Free Software
 17  
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  
 ////////////////////////////////////////////////////////////////////////////////
 19  
 package com.puppycrawl.tools.checkstyle.api;
 20  
 
 21  
 import com.google.common.collect.ImmutableMap;
 22  
 import java.util.Map;
 23  
 
 24  
 /**
 25  
  * This enum defines the various Javadoc tags and there properties.
 26  
  *
 27  
  * <p>
 28  
  * This class was modeled after documentation located at
 29  
  * <a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html">
 30  
  * javadoc</a>
 31  
  *
 32  
  * and
 33  
  *
 34  
  * <a href="http://java.sun.com/j2se/javadoc/writingdoccomments/index.html">
 35  
  * how to write</a>.
 36  
  * </p>
 37  
  *
 38  
  * <p>
 39  
  * Some of this documentation was a little incomplete (ex: valid placement of
 40  
  * code, value, and literal tags).
 41  
  * </p>
 42  
  *
 43  
  * <p>
 44  
  * Whenever an inconsistency was found the author's judgment was used.
 45  
  * </p>
 46  
  *
 47  
  * <p>
 48  
  * For now, the number of required/optional tag arguments are not included
 49  
  * because some Javadoc tags have very complex rules for determining this
 50  
  * (ex: {@code {@value}} tag).
 51  
  * </p>
 52  
  *
 53  
  * <p>
 54  
  * Also, the {@link #isValidOn(DetailAST) isValidOn} method does not consider
 55  
  * classes defined in a local code block (method, init block, etc.).
 56  
  * </>
 57  
  *
 58  
  * @author Travis Schneeberger
 59  
  */
 60  21
 public enum JavadocTagInfo
 61  
 {
 62  
     /**
 63  
      * {@code @author}.
 64  
      */
 65  1
     AUTHOR("@author", "author", Type.BLOCK, true, true)
 66  
     {
 67  
         /** {@inheritDoc} */
 68  
         @Override
 69  
         public boolean isValidOn(final DetailAST aAst)
 70  
         {
 71  0
             final int type = aAst.getType();
 72  0
             return type == TokenTypes.PACKAGE_DEF
 73  
                 || type == TokenTypes.CLASS_DEF
 74  
                 || type == TokenTypes.INTERFACE_DEF
 75  
                 || type == TokenTypes.ENUM_DEF
 76  
                 || type == TokenTypes.ANNOTATION_DEF;
 77  
         }
 78  
     },
 79  
 
 80  
     /**
 81  
      * {@code {@code}}.
 82  
      */
 83  1
     CODE("{@code}", "code", Type.INLINE, true, true)
 84  
     {
 85  
         /** {@inheritDoc} */
 86  
         @Override
 87  
         public boolean isValidOn(final DetailAST aAst)
 88  
         {
 89  0
             final int type = aAst.getType();
 90  0
             return type == TokenTypes.PACKAGE_DEF
 91  
                 || type == TokenTypes.CLASS_DEF
 92  
                 || type == TokenTypes.INTERFACE_DEF
 93  
                 || type == TokenTypes.ENUM_DEF
 94  
                 || type == TokenTypes.ANNOTATION_DEF
 95  
                 || type == TokenTypes.METHOD_DEF
 96  
                 || type == TokenTypes.CTOR_DEF
 97  
                 || (type == TokenTypes.VARIABLE_DEF
 98  
                 && !ScopeUtils.isLocalVariableDef(aAst));
 99  
         }
 100  
     },
 101  
 
 102  
     /**
 103  
      * {@code {@docRoot}}.
 104  
      */
 105  1
     DOC_ROOT("{@docRoot}", "docRoot", Type.INLINE, true, true)
 106  
     {
 107  
         /** {@inheritDoc} */
 108  
         @Override
 109  
         public boolean isValidOn(final DetailAST aAst)
 110  
         {
 111  0
             final int type = aAst.getType();
 112  0
             return type == TokenTypes.PACKAGE_DEF
 113  
                 || type == TokenTypes.CLASS_DEF
 114  
                 || type == TokenTypes.INTERFACE_DEF
 115  
                 || type == TokenTypes.ENUM_DEF
 116  
                 || type == TokenTypes.ANNOTATION_DEF
 117  
                 || type == TokenTypes.METHOD_DEF || type == TokenTypes.CTOR_DEF
 118  
                 || (type == TokenTypes.VARIABLE_DEF
 119  
                 && !ScopeUtils.isLocalVariableDef(aAst));
 120  
         }
 121  
     },
 122  
 
 123  
     /**
 124  
      * {@code @deprecated}.
 125  
      */
 126  1
     DEPRECATED("@deprecated", "deprecated", Type.BLOCK, false, false)
 127  
     {
 128  
         /** {@inheritDoc} */
 129  
         @Override
 130  
         public boolean isValidOn(final DetailAST aAst)
 131  
         {
 132  0
             final int type = aAst.getType();
 133  0
             return type == TokenTypes.CLASS_DEF
 134  
                 || type == TokenTypes.INTERFACE_DEF
 135  
                 || type == TokenTypes.ENUM_DEF
 136  
                 || type == TokenTypes.ANNOTATION_DEF
 137  
                 || type == TokenTypes.METHOD_DEF
 138  
                 || type == TokenTypes.CTOR_DEF
 139  
                 || type == TokenTypes.ENUM_CONSTANT_DEF
 140  
                 || type == TokenTypes.ANNOTATION_FIELD_DEF
 141  
                 || (type == TokenTypes.VARIABLE_DEF
 142  
                 && !ScopeUtils.isLocalVariableDef(aAst));
 143  
         }
 144  
     },
 145  
 
 146  
     /**
 147  
      * {@code @exception}.
 148  
      */
 149  1
     EXCEPTION("@exception", "exception", Type.BLOCK, false, false)
 150  
     {
 151  
         /** {@inheritDoc} */
 152  
         @Override
 153  
         public boolean isValidOn(final DetailAST aAst)
 154  
         {
 155  0
             final int type = aAst.getType();
 156  0
             return type == TokenTypes.METHOD_DEF || type == TokenTypes.CTOR_DEF;
 157  
         }
 158  
     },
 159  
 
 160  
     /**
 161  
      * {@code {@inheritDoc}}.
 162  
      */
 163  1
     INHERIT_DOC("{@inheritDoc}", "inheritDoc", Type.INLINE, false, false)
 164  
     {
 165  
         /** {@inheritDoc} */
 166  
         @Override
 167  
         public boolean isValidOn(final DetailAST aAst)
 168  
         {
 169  83
             final int type = aAst.getType();
 170  
 
 171  83
             return type == TokenTypes.METHOD_DEF
 172  
                 && !aAst.branchContains(TokenTypes.LITERAL_STATIC)
 173  
                 && ScopeUtils.getScopeFromMods(aAst
 174  
                     .findFirstToken(TokenTypes.MODIFIERS)) != Scope.PRIVATE;
 175  
         }
 176  
     },
 177  
 
 178  
     /**
 179  
      * {@code {@link}}.
 180  
      */
 181  1
     LINK("{@link}", "link", Type.INLINE, true, true)
 182  
     {
 183  
         /** {@inheritDoc} */
 184  
         @Override
 185  
         public boolean isValidOn(final DetailAST aAst)
 186  
         {
 187  0
             final int type = aAst.getType();
 188  0
             return type == TokenTypes.PACKAGE_DEF
 189  
                 || type == TokenTypes.CLASS_DEF
 190  
                 || type == TokenTypes.INTERFACE_DEF
 191  
                 || type == TokenTypes.ENUM_DEF
 192  
                 || type == TokenTypes.ANNOTATION_DEF
 193  
                 || type == TokenTypes.METHOD_DEF || type == TokenTypes.CTOR_DEF
 194  
                 || (type == TokenTypes.VARIABLE_DEF
 195  
                 && !ScopeUtils.isLocalVariableDef(aAst));
 196  
         }
 197  
     },
 198  
 
 199  
     /**
 200  
      * {@code {@linkplain}}.
 201  
      */
 202  1
     LINKPLAIN("{@linkplain}", "linkplain", Type.INLINE, true, true)
 203  
     {
 204  
         /** {@inheritDoc} */
 205  
         @Override
 206  
         public boolean isValidOn(final DetailAST aAst)
 207  
         {
 208  0
             final int type = aAst.getType();
 209  0
             return type == TokenTypes.PACKAGE_DEF
 210  
                 || type == TokenTypes.CLASS_DEF
 211  
                 || type == TokenTypes.INTERFACE_DEF
 212  
                 || type == TokenTypes.ENUM_DEF
 213  
                 || type == TokenTypes.ANNOTATION_DEF
 214  
                 || type == TokenTypes.METHOD_DEF || type == TokenTypes.CTOR_DEF
 215  
                 || (type == TokenTypes.VARIABLE_DEF
 216  
                 && !ScopeUtils.isLocalVariableDef(aAst));
 217  
         }
 218  
     },
 219  
 
 220  
     /**
 221  
      * {@code {@literal}}.
 222  
      */
 223  1
     LITERAL("{@literal}", "literal", Type.INLINE, true, true)
 224  
     {
 225  
         /** {@inheritDoc} */
 226  
         @Override
 227  
         public boolean isValidOn(final DetailAST aAst)
 228  
         {
 229  0
             final int type = aAst.getType();
 230  0
             return type == TokenTypes.PACKAGE_DEF
 231  
                 || type == TokenTypes.CLASS_DEF
 232  
                 || type == TokenTypes.INTERFACE_DEF
 233  
                 || type == TokenTypes.ENUM_DEF
 234  
                 || type == TokenTypes.ANNOTATION_DEF
 235  
                 || type == TokenTypes.METHOD_DEF || type == TokenTypes.CTOR_DEF
 236  
                 || (type == TokenTypes.VARIABLE_DEF
 237  
                 && !ScopeUtils.isLocalVariableDef(aAst));
 238  
         }
 239  
     },
 240  
 
 241  
     /**
 242  
      * {@code @param}.
 243  
      */
 244  1
     PARAM("@param", "param", Type.BLOCK, false, false)
 245  
     {
 246  
         /** {@inheritDoc} */
 247  
         @Override
 248  
         public boolean isValidOn(final DetailAST aAst)
 249  
         {
 250  0
             final int type = aAst.getType();
 251  0
             return type == TokenTypes.CLASS_DEF
 252  
                 || type == TokenTypes.INTERFACE_DEF
 253  
                 || type == TokenTypes.METHOD_DEF
 254  
                 || type == TokenTypes.CTOR_DEF;
 255  
         }
 256  
     },
 257  
 
 258  
     /**
 259  
      * {@code @return}.
 260  
      */
 261  1
     RETURN("@return", "return", Type.BLOCK, false, false)
 262  
     {
 263  
         /** {@inheritDoc} */
 264  
         @Override
 265  
         public boolean isValidOn(final DetailAST aAst)
 266  
         {
 267  0
             final int type = aAst.getType();
 268  0
             final DetailAST returnType = aAst.findFirstToken(TokenTypes.TYPE);
 269  
 
 270  0
             return type == TokenTypes.METHOD_DEF
 271  
                 && returnType.getFirstChild().getType()
 272  
                 != TokenTypes.LITERAL_VOID;
 273  
 
 274  
         }
 275  
     },
 276  
 
 277  
     /**
 278  
      * {@code @see}.
 279  
      */
 280  1
     SEE("@see", "see", Type.BLOCK, true, true)
 281  
     {
 282  
         /** {@inheritDoc} */
 283  
         @Override
 284  
         public boolean isValidOn(final DetailAST aAst)
 285  
         {
 286  0
             final int type = aAst.getType();
 287  0
             return type == TokenTypes.PACKAGE_DEF
 288  
                 || type == TokenTypes.CLASS_DEF
 289  
                 || type == TokenTypes.INTERFACE_DEF
 290  
                 || type == TokenTypes.ENUM_DEF
 291  
                 || type == TokenTypes.ANNOTATION_DEF
 292  
                 || type == TokenTypes.METHOD_DEF
 293  
                 || type == TokenTypes.CTOR_DEF
 294  
                 || (type == TokenTypes.VARIABLE_DEF
 295  
                 && !ScopeUtils.isLocalVariableDef(aAst));
 296  
         }
 297  
     },
 298  
 
 299  
     /**
 300  
      * {@code @serial}.
 301  
      */
 302  1
     SERIAL("@serial", "serial", Type.BLOCK, true, false)
 303  
     {
 304  
         /** {@inheritDoc} */
 305  
         @Override
 306  
         public boolean isValidOn(final DetailAST aAst)
 307  
         {
 308  0
             final int type = aAst.getType();
 309  
 
 310  0
             return type == TokenTypes.VARIABLE_DEF
 311  
                 && !ScopeUtils.isLocalVariableDef(aAst);
 312  
         }
 313  
     },
 314  
 
 315  
     /**
 316  
      * {@code @serialData}.
 317  
      */
 318  1
     SERIAL_DATA("@serialData", "serialData", Type.BLOCK, false, false)
 319  
     {
 320  
         /** {@inheritDoc} */
 321  
         @Override
 322  
         public boolean isValidOn(final DetailAST aAst)
 323  
         {
 324  0
             final int type = aAst.getType();
 325  0
             final DetailAST methodNameAst = aAst
 326  
                 .findFirstToken(TokenTypes.IDENT);
 327  0
             final String methodName = methodNameAst.getText();
 328  
 
 329  0
             return type == TokenTypes.METHOD_DEF
 330  
                 && ("writeObject".equals(methodName)
 331  
                     || "readObject".equals(methodName)
 332  
                     || "writeExternal".equals(methodName)
 333  
                     || "readExternal".equals(methodName)
 334  
                     || "writeReplace".equals(methodName)
 335  
                     || "readResolve"
 336  
                     .equals(methodName));
 337  
         }
 338  
     },
 339  
 
 340  
     /**
 341  
      * {@code @serialField}.
 342  
      */
 343  1
     SERIAL_FIELD("@serialField", "serialField", Type.BLOCK, false, false)
 344  
     {
 345  
         /** {@inheritDoc} */
 346  
         @Override
 347  
         public boolean isValidOn(final DetailAST aAst)
 348  
         {
 349  0
             final int type = aAst.getType();
 350  0
             final DetailAST varType = aAst.findFirstToken(TokenTypes.TYPE);
 351  
 
 352  0
             return type == TokenTypes.VARIABLE_DEF
 353  
                 && varType.getType() == TokenTypes.ARRAY_DECLARATOR
 354  
                 && "ObjectStreamField"
 355  
                     .equals(varType.getFirstChild().getText());
 356  
         }
 357  
     },
 358  
 
 359  
     /**
 360  
      * {@code @since}.
 361  
      */
 362  1
     SINCE("@since", "since", Type.BLOCK, true, true)
 363  
     {
 364  
         /** {@inheritDoc} */
 365  
         @Override
 366  
         public boolean isValidOn(final DetailAST aAst)
 367  
         {
 368  0
             final int type = aAst.getType();
 369  0
             return type == TokenTypes.PACKAGE_DEF
 370  
                 || type == TokenTypes.CLASS_DEF
 371  
                 || type == TokenTypes.INTERFACE_DEF
 372  
                 || type == TokenTypes.ENUM_DEF
 373  
                 || type == TokenTypes.ANNOTATION_DEF
 374  
                 || type == TokenTypes.METHOD_DEF
 375  
                 || type == TokenTypes.CTOR_DEF
 376  
                 || (type == TokenTypes.VARIABLE_DEF
 377  
                 && !ScopeUtils.isLocalVariableDef(aAst));
 378  
         }
 379  
     },
 380  
 
 381  
     /**
 382  
      * {@code @throws}.
 383  
      */
 384  1
     THROWS("@throws", "throws", Type.BLOCK, false, false)
 385  
     {
 386  
         /** {@inheritDoc} */
 387  
         @Override
 388  
         public boolean isValidOn(final DetailAST aAst)
 389  
         {
 390  0
             final int type = aAst.getType();
 391  0
             return type == TokenTypes.METHOD_DEF
 392  
                 || type == TokenTypes.CTOR_DEF;
 393  
         }
 394  
     },
 395  
 
 396  
     /**
 397  
      * {@code {@value}}.
 398  
      */
 399  1
     VALUE("{@value}", "value", Type.INLINE, true, true)
 400  
     {
 401  
         /** {@inheritDoc} */
 402  
         @Override
 403  
         public boolean isValidOn(final DetailAST aAst)
 404  
         {
 405  0
             final int type = aAst.getType();
 406  0
             return type == TokenTypes.PACKAGE_DEF
 407  
                 || type == TokenTypes.CLASS_DEF
 408  
                 || type == TokenTypes.INTERFACE_DEF
 409  
                 || type == TokenTypes.ENUM_DEF
 410  
                 || type == TokenTypes.ANNOTATION_DEF
 411  
                 || type == TokenTypes.METHOD_DEF
 412  
                 || type == TokenTypes.CTOR_DEF
 413  
                 || (type == TokenTypes.VARIABLE_DEF
 414  
                 && !ScopeUtils.isLocalVariableDef(aAst));
 415  
         }
 416  
     },
 417  
 
 418  
     /**
 419  
      * {@code @version}.
 420  
      */
 421  1
     VERSION("@version", "version", Type.BLOCK, true, true)
 422  
     {
 423  
         /** {@inheritDoc} */
 424  
         @Override
 425  
         public boolean isValidOn(final DetailAST aAst)
 426  
         {
 427  0
             final int type = aAst.getType();
 428  0
             return type == TokenTypes.PACKAGE_DEF
 429  
                 || type == TokenTypes.CLASS_DEF
 430  
                 || type == TokenTypes.INTERFACE_DEF
 431  
                 || type == TokenTypes.ENUM_DEF
 432  
                 || type == TokenTypes.ANNOTATION_DEF;
 433  
         }
 434  
     };
 435  
 
 436  
     /** holds tag text to tag enum mappings **/
 437  
     private static final Map<String, JavadocTagInfo> TEXT_TO_TAG;
 438  
     /** holds tag name to tag enum mappings **/
 439  
     private static final Map<String, JavadocTagInfo> NAME_TO_TAG;
 440  
 
 441  
     static
 442  
     {
 443  1
         final ImmutableMap.Builder<String, JavadocTagInfo> textToTagBuilder =
 444  
             new ImmutableMap.Builder<String, JavadocTagInfo>();
 445  
 
 446  1
         final ImmutableMap.Builder<String, JavadocTagInfo> nameToTagBuilder =
 447  
             new ImmutableMap.Builder<String, JavadocTagInfo>();
 448  
 
 449  20
         for (final JavadocTagInfo tag : JavadocTagInfo.values()) {
 450  19
             textToTagBuilder.put(tag.getText(), tag);
 451  19
             nameToTagBuilder.put(tag.getName(), tag);
 452  
         }
 453  
 
 454  1
         TEXT_TO_TAG = textToTagBuilder.build();
 455  1
         NAME_TO_TAG = nameToTagBuilder.build();
 456  1
     }
 457  
 
 458  
     /** the tag text **/
 459  
     private final String mText;
 460  
     /** the tag name **/
 461  
     private final String mName;
 462  
     /** the tag type **/
 463  
     private final Type mType;
 464  
     /** if tag is valid in package.html **/
 465  
     private final boolean mValidInPackageHtml;
 466  
     /** if tag is valid in overview.html **/
 467  
     private final boolean mValidInOverviewHtml;
 468  
 
 469  
     /**
 470  
      * Sets the various properties of a Javadoc tag.
 471  
      *
 472  
      * @param aText the tag text
 473  
      * @param aName the tag name
 474  
      * @param aType the type of tag
 475  
      * @param aValidInPackageHtml whether the tag is valid
 476  
      * in package.html file
 477  
      * @param aValidInOverviewHtml whether the tag is valid
 478  
      * in overview.html file
 479  
      */
 480  
     private JavadocTagInfo(final String aText, final String aName,
 481  
         final Type aType, final boolean aValidInPackageHtml,
 482  
         final boolean aValidInOverviewHtml)
 483  19
     {
 484  19
         this.mText = aText;
 485  19
         this.mName = aName;
 486  19
         this.mType = aType;
 487  19
         this.mValidInPackageHtml = aValidInPackageHtml;
 488  19
         this.mValidInOverviewHtml = aValidInOverviewHtml;
 489  19
     }
 490  
 
 491  
     /**
 492  
      * Checks if a particular Javadoc tag is valid within a Javadoc block of a
 493  
      * given AST.
 494  
      *
 495  
      * <p>
 496  
      * For example: Given a call to
 497  
      * <code>JavadocTag.RETURN{@link #isValidOn(DetailAST)}</code>.
 498  
      * </p>
 499  
      *
 500  
      * <p>
 501  
      * If passing in a DetailAST representing a non-void METHOD_DEF
 502  
      * <code> true </code> would be returned. If passing in a DetailAST
 503  
      * representing a CLASS_DEF <code> false </code> would be returned because
 504  
      * CLASS_DEF's cannot return a value.
 505  
      * </p>
 506  
      *
 507  
      * @param aAST the AST representing a type that can be Javadoc'd
 508  
      * @return true if tag is valid.
 509  
      */
 510  
     public abstract boolean isValidOn(DetailAST aAST);
 511  
 
 512  
     /**
 513  
      * Checks if tag is valid in a package.html Javadoc file.
 514  
      *
 515  
      * @return true if tag is valid.
 516  
      */
 517  
     public boolean isValidInPackageHtml()
 518  
     {
 519  0
         return this.mValidInPackageHtml;
 520  
     }
 521  
 
 522  
     /**
 523  
      * Checks if tag is valid in a overview.html Javadoc file.
 524  
      *
 525  
      * @return true if tag is valid.
 526  
      */
 527  
     public boolean isValidInOverviewHtml()
 528  
     {
 529  0
         return this.mValidInOverviewHtml;
 530  
     }
 531  
 
 532  
     /**
 533  
      * Gets the tag text.
 534  
      * @return the tag text
 535  
      */
 536  
     public String getText()
 537  
     {
 538  95
         return this.mText;
 539  
     }
 540  
 
 541  
     /**
 542  
      * Gets the tag name.
 543  
      * @return the tag name
 544  
      */
 545  
     public String getName()
 546  
     {
 547  231
         return this.mName;
 548  
     }
 549  
 
 550  
     /**
 551  
      * Gets the Tag type defined by {@link JavadocTagInfo.Type Type}.
 552  
      * @return the Tag type
 553  
      */
 554  
     public Type getType()
 555  
     {
 556  0
         return this.mType;
 557  
     }
 558  
 
 559  
     /**
 560  
      * returns a JavadocTag from the tag text.
 561  
      * @param aText String representing the tag text
 562  
      * @return Returns a JavadocTag type from a String representing the tag
 563  
      * @throws NullPointerException if the text is null
 564  
      * @throws IllegalArgumentException if the text is not a valid tag
 565  
      */
 566  
     public static JavadocTagInfo fromText(final String aText)
 567  
     {
 568  0
         if (aText == null) {
 569  0
             throw new NullPointerException("the text is null");
 570  
         }
 571  
 
 572  0
         final JavadocTagInfo tag = TEXT_TO_TAG.get(aText);
 573  
 
 574  0
         if (tag == null) {
 575  0
             throw new IllegalArgumentException("the text [" + aText
 576  
                 + "] is not a valid Javadoc tag text");
 577  
         }
 578  
 
 579  0
         return tag;
 580  
     }
 581  
 
 582  
     /**
 583  
      * returns a JavadocTag from the tag name.
 584  
      * @param aName String name of the tag
 585  
      * @return Returns a JavadocTag type from a String representing the tag
 586  
      * @throws NullPointerException if the text is null
 587  
      * @throws IllegalArgumentException if the text is not a valid tag. The name
 588  
      *    can be checked using {@link JavadocTagInfo#isValidName(String)}
 589  
      */
 590  
     public static JavadocTagInfo fromName(final String aName)
 591  
     {
 592  309
         if (aName == null) {
 593  0
             throw new NullPointerException("the name is null");
 594  
         }
 595  
 
 596  309
         final JavadocTagInfo tag = NAME_TO_TAG.get(aName);
 597  
 
 598  309
         if (tag == null) {
 599  0
             throw new IllegalArgumentException("the name [" + aName
 600  
                 + "] is not a valid Javadoc tag name");
 601  
         }
 602  
 
 603  309
         return tag;
 604  
     }
 605  
 
 606  
     /**
 607  
      * Returns whether the provided name is for a valid tag.
 608  
      * @param aName the tag name to check.
 609  
      * @return whether the provided name is for a valid tag.
 610  
      */
 611  
     public static boolean isValidName(final String aName)
 612  
     {
 613  120
         return NAME_TO_TAG.containsKey(aName);
 614  
     }
 615  
 
 616  
     /**
 617  
      * {@inheritDoc}
 618  
      */
 619  
     @Override
 620  
     public String toString()
 621  
     {
 622  0
         return "text [" + this.mText + "] name [" + this.mName
 623  
             + "] type [" + this.mType
 624  
             + "] validInPackageHtml [" + this.mValidInPackageHtml
 625  
             + "] validInOverviewHtml [" + this.mValidInOverviewHtml + "]";
 626  
     }
 627  
 
 628  
     /**
 629  
      * The Javadoc Type.
 630  
      *
 631  
      * For example a {@code @param} tag is a block tag while a
 632  
      * {@code {@link}} tag is a inline tag.
 633  
      *
 634  
      * @author Travis Schneeberger
 635  
      */
 636  3
     public enum Type
 637  
     {
 638  
         /** block type. **/
 639  1
         BLOCK,
 640  
 
 641  
         /** inline type. **/
 642  1
         INLINE;
 643  
     }
 644  
 }