View Javadoc
1   /*
2   JavadocMethod
3   allowedAnnotations = (default)Override
4   validateThrows = true
5   accessModifiers = (default)public, protected, package, private
6   allowMissingParamTags = (default)false
7   allowMissingReturnTag = (default)false
8   tokens = (default)METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF, COMPACT_CTOR_DEF
9   
10  
11  */
12  
13  package com.puppycrawl.tools.checkstyle.checks.javadoc.javadocmethod;
14  
15  public class InputJavadocMethodExtraThrowsOne {
16  
17      /**
18       * Extra throws in javadoc it is ok.
19       * @param properties some value
20       * @throws IllegalArgumentException when argument is wrong
21       * @throws NullPointerException indicates null was passed
22       */
23      public  InputJavadocMethodExtraThrowsOne(String properties) {
24          // here is NPE possible
25          if (properties.charAt(0) == 0) {
26              throw new IllegalArgumentException("cannot have char with code 0");
27          }
28      }
29  
30      /**
31       * Extra throws in javadoc it is ok
32       * @param properties some value
33       * @throws java.lang.IllegalArgumentException when argument is wrong
34       * @throws java.lang.NullPointerException indicates null was passed
35       */
36      public void doSomething1(String properties) throws IllegalArgumentException {
37          // here is NPE possible
38          if (properties.charAt(0) == 0) {
39              throw new IllegalArgumentException("cannot have char with code 0");
40          }
41      }
42  
43      /**
44       * declared exception in method signature is missed in javadoc
45       * @param properties some value
46       * @throws java.lang.IllegalArgumentException when argument is wrong
47       * @throws java.lang.NullPointerException indicates null was passed
48       */
49      // violation below 'Expected @throws tag for 'IllegalStateException'.'
50      public void doSomething2(String properties) throws IllegalStateException {
51          // here is NPE possible
52          if (properties.charAt(0) == 0) {
53              throw new IllegalArgumentException("cannot have char with code 0");
54          }
55      }
56  
57      /**
58       * exception is explitly thrown in code missed in javadoc
59       * @param properties some value
60       * @throws java.lang.IllegalStateException when argument is wrong
61       */
62      public void doSomething3(String properties) throws IllegalStateException {
63          // here is NPE possible
64          if (properties.charAt(0) == 0) {
65              // violation below 'Expected @throws tag for 'IllegalArgumentException'.'
66              throw new IllegalArgumentException("cannot have char with code 0");
67          }
68      }
69  
70      /**
71       * exception is explitly thrown in code missed in javadoc
72       * @param properties some value
73       * @throws java.lang.IllegalStateException when argument is wrong
74       */
75      public void doSomething4(String properties) {
76          // here is NPE possible
77          if (properties.charAt(0) == 0) {
78              // violation below 'Expected @throws tag for 'IllegalArgumentException'.'
79              throw new IllegalArgumentException("cannot have char with code 0");
80          }
81      }
82  
83      /**
84       * exception is explitly thrown in code missed in javadoc
85       * @param properties some value
86       * @throws java.lang.IllegalStateException when argument is wrong
87       */
88      public void doSomething5(String properties) {
89          // here is NPE possible
90          if (properties.charAt(0) == 0) {
91              // violation below 'Expected @throws tag for 'java.lang.IllegalArgumentException'.'
92              throw new java.lang.IllegalArgumentException(
93                      "cannot have char with code 0");
94          }
95      }
96  
97      /**
98       * expicitly throwed is declared in javadoc
99       * @param properties some value
100      * @throws IllegalArgumentException when argument is wrong
101      */
102     public void doSomething6(String properties) {
103         // here is NPE possible
104         if (properties.charAt(0) == 0) {
105             throw new java.lang.IllegalArgumentException("cannot have char with code 0");
106         }
107     }
108 }