View Javadoc

1   package org.apache.maven.shared.utils.reflection;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *  http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  /**
22   *
23   * @author stephenc
24   */
25  class ReflectorTestHelper
26  {
27      private static String PRIVATE_STATIC_STRING = "private static string";
28      static String PACKAGE_STATIC_STRING = "package static string";
29      protected static String PROTECTED_STATIC_STRING = "protected static string";
30      public static String PUBLIC_STATIC_STRING = "public static string";
31  
32      private ReflectorTestHelper()
33      {
34      }
35  
36      ReflectorTestHelper( Boolean throwSomething )
37      {
38          if ( Boolean.TRUE.equals( throwSomething ) )
39          {
40              throw new HelperException( "Something" );
41          }
42      }
43  
44      protected ReflectorTestHelper( Integer throwCount )
45      {
46          if ( throwCount != null && throwCount.intValue() > 0 )
47          {
48              throw new HelperException( "Something" );
49          }
50      }
51  
52      public ReflectorTestHelper( String throwMessage )
53      {
54          if ( throwMessage != null && throwMessage.length() > 0  )
55          {
56              throw new HelperException( throwMessage );
57          }
58      }
59  
60      private static ReflectorTestHelper getInstance()
61      {
62          return new ReflectorTestHelper();
63      }
64  
65      static ReflectorTestHelper getInstance( Boolean throwSomething )
66      {
67          if ( Boolean.TRUE.equals( throwSomething ) )
68          {
69              throw new HelperException( "Something" );
70          }
71          return new ReflectorTestHelper();
72      }
73  
74      protected static ReflectorTestHelper getInstance( Integer throwCount )
75      {
76          if ( throwCount != null && throwCount.intValue() > 0 )
77          {
78              throw new HelperException( "Something" );
79          }
80          return new ReflectorTestHelper();
81      }
82  
83      public static ReflectorTestHelper getInstance( String throwMessage )
84      {
85          if ( throwMessage != null && throwMessage.length() > 0 )
86          {
87              throw new HelperException( throwMessage );
88          }
89          return new ReflectorTestHelper();
90      }
91  
92      public ReflectorTestHelper getInstance( String aString, Boolean aBoolean )
93      {
94          return new ReflectorTestHelper();
95      }
96  
97      public static class HelperException
98          extends RuntimeException
99      {
100         public HelperException()
101         {
102             super();    //To change body of overridden methods use File | Settings | File Templates.
103         }
104 
105         public HelperException( String message )
106         {
107             super( message );    //To change body of overridden methods use File | Settings | File Templates.
108         }
109 
110         public HelperException( String message, Throwable cause )
111         {
112             super( message, cause );    //To change body of overridden methods use File | Settings | File Templates.
113         }
114 
115         public HelperException( Throwable cause )
116         {
117             super( cause );    //To change body of overridden methods use File | Settings | File Templates.
118         }
119     }
120 }