View Javadoc
1   /*
2    *  Copyright 2012 Chris Pheby
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.jadira.scanner.classpath.types;
17  
18  import javassist.bytecode.MethodInfo;
19  
20  import org.apache.commons.lang3.builder.EqualsBuilder;
21  import org.apache.commons.lang3.builder.HashCodeBuilder;
22  import org.jadira.scanner.classpath.ClasspathResolver;
23  import org.jadira.scanner.classpath.visitor.IntrospectionVisitor;
24  import org.jadira.scanner.core.exception.ClasspathAccessException;
25  
26  public class JStaticInitializer extends JOperation {
27  
28      protected JStaticInitializer(MethodInfo methodInfo, JType enclosingType, ClasspathResolver resolver) {
29          super(methodInfo, enclosingType, resolver);
30      }
31  
32      public static JStaticInitializer getJStaticInitializer(MethodInfo methodInfo, JType enclosingType, ClasspathResolver resolver) {
33          return new JStaticInitializer(methodInfo, enclosingType, resolver);
34      }
35  
36      @Override
37      public void acceptVisitor(IntrospectionVisitor visitor) throws ClasspathAccessException {
38          visitor.visit(this);
39  
40          for (JParameter next : getParameters()) {
41              next.acceptVisitor(visitor);
42          }
43          for (JAnnotation<?> next : getAnnotations()) {
44              next.acceptVisitor(visitor);
45          }
46      }
47      
48      @Override
49  	public boolean equals(Object obj) {
50  		if (obj == null) {
51  			return false;
52  		}
53  		if (obj == this) {
54  			return true;
55  		}
56  		if (obj.getClass() != getClass()) {
57  			return false;
58  		}
59  		// JStaticInitializer rhs = (JStaticInitializer) obj;
60  		return new EqualsBuilder()
61  			 	.appendSuper(super.equals(obj))
62  				.isEquals();
63  	}
64  
65      @Override
66  	public int hashCode() {
67  		return new HashCodeBuilder(11, 47).append(super.hashCode())
68  				.toHashCode();
69  	}
70  }