View Javadoc
1   package integrationTests;
2   
3   import org.slf4j.Logger;
4   import org.slf4j.LoggerFactory;
5   
6   /**
7    * The Class ClassWithNestedClasses.
8    */
9   public class ClassWithNestedClasses {
10  
11      /** The logger. */
12      private static final Logger logger = LoggerFactory.getLogger(ClassWithNestedClasses.class);
13  
14      /**
15       * The Class NestedClass.
16       */
17      public static class NestedClass {
18  
19          /** The i. */
20          private final int i;
21  
22          /**
23           * Instantiates a new nested class.
24           */
25          public NestedClass() {
26              i = 123;
27          }
28  
29          /**
30           * The Class DeeplyNestedClass.
31           */
32          private static final class DeeplyNestedClass {
33  
34              /**
35               * Prints the.
36               *
37               * @param text
38               *            the text
39               */
40              void print(String text) {
41                  logger.info(text);
42              }
43          }
44  
45          /**
46           * The Class InnerClass.
47           */
48          private final class InnerClass {
49  
50              /**
51               * Prints the.
52               *
53               * @param text
54               *            the text
55               */
56              void print(String text) {
57                  logger.info("{}: {}", text, i);
58              }
59          }
60      }
61  
62      /**
63       * Do something.
64       */
65      public static void doSomething() {
66          new NestedClass.DeeplyNestedClass().print("test");
67  
68          // Just so we have two paths:
69          if (logger != null) {
70              logger.info("Test");
71          }
72      }
73  
74      /**
75       * Method containing anonymous class.
76       *
77       * @param i
78       *            the i
79       *
80       * @return true, if successful
81       */
82      public static boolean methodContainingAnonymousClass(int i) {
83          new Cloneable() {
84          };
85          return i > 0;
86      }
87  }