1   package com.stateofflow.eclipse.metrics.calculators.complexity;
2   
3   final class Complexity {
4       private int classComplexity;
5       private int methodComplexity;
6   
7       public Complexity() {
8       }
9   
10      public Complexity(final Complexity toCopy) {
11          classComplexity = toCopy.classComplexity;
12          methodComplexity = toCopy.methodComplexity;
13      }
14  
15      public int getClassComplexity() {
16          return classComplexity;
17      }
18  
19      public int getMethodComplexity() {
20          return methodComplexity;
21      }
22  
23      public void handleNestedClass(final boolean inMethod, final Complexity inner) {
24          if (inMethod) {
25              methodComplexity += inner.classComplexity;
26          } else {
27              classComplexity += inner.classComplexity;
28          }
29      }
30  
31      public void increment() {
32          methodComplexity++;
33          classComplexity++;
34      }
35  
36      public void startMethod() {
37          methodComplexity = 1;
38          classComplexity++;
39      }
40  
41      public void startType() {
42          classComplexity = 0;
43      }
44  }
45