Source code: com/puppycrawl/tools/checkstyle/bcel/classfile/Utils.java
1 package com.puppycrawl.tools.checkstyle.bcel.classfile;
2
3 import java.util.Set;
4
5 import org.apache.bcel.classfile.FieldOrMethod;
6
7 import com.puppycrawl.tools.checkstyle.api.Scope;
8
9 /**
10 * Utility methods for BCEL classfile package
11 * @author Rick Giles
12 */
13 public class Utils
14 {
15 /**
16 * Determines whether the declared scope of a field or method is in
17 * a set of scopes.
18 * @param aFieldOrMethod the field or method to test.
19 * @param aScopes the set of scopes to test against.
20 * @return true if the declared scope of aFieldOrMethod is in aScopes.
21 */
22 public static boolean inScope(FieldOrMethod aFieldOrMethod, Set aScopes)
23 {
24 if (aFieldOrMethod.isPrivate()) {
25 return (aScopes.contains(Scope.PRIVATE));
26 }
27 else if (aFieldOrMethod.isProtected()) {
28 return (aScopes.contains(Scope.PROTECTED));
29 }
30 else if (aFieldOrMethod.isPublic()) {
31 return (aScopes.contains(Scope.PUBLIC));
32 }
33 else {
34 return (aScopes.contains(Scope.PACKAGE));
35 }
36 }
37
38
39 }