01: package com.puppycrawl.tools.checkstyle.bcel.classfile;
02:
03: import java.util.Set;
04:
05: import org.apache.bcel.classfile.FieldOrMethod;
06:
07: import com.puppycrawl.tools.checkstyle.api.Scope;
08:
09: /**
10: * Utility methods for BCEL classfile package
11: * @author Rick Giles
12: */
13: public class Utils {
14: /**
15: * Determines whether the declared scope of a field or method is in
16: * a set of scopes.
17: * @param aFieldOrMethod the field or method to test.
18: * @param aScopes the set of scopes to test against.
19: * @return true if the declared scope of aFieldOrMethod is in aScopes.
20: */
21: public static boolean inScope(FieldOrMethod aFieldOrMethod,
22: Set aScopes) {
23: if (aFieldOrMethod.isPrivate()) {
24: return (aScopes.contains(Scope.PRIVATE));
25: } else if (aFieldOrMethod.isProtected()) {
26: return (aScopes.contains(Scope.PROTECTED));
27: } else if (aFieldOrMethod.isPublic()) {
28: return (aScopes.contains(Scope.PUBLIC));
29: } else {
30: return (aScopes.contains(Scope.PACKAGE));
31: }
32: }
33:
34: }
|