summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/analysis/Access.java
diff options
context:
space:
mode:
authorGravatar jeff2014-08-28 19:34:17 -0400
committerGravatar jeff2014-08-28 19:34:17 -0400
commit029f65d110279288f4cad7fb7cfaa33efd0f207d (patch)
treec4bbf3765c2d3021c7311b7953c1a0c2da7b6cef /src/cuchaz/enigma/analysis/Access.java
parentfixed minor spelling error (diff)
downloadenigma-fork-029f65d110279288f4cad7fb7cfaa33efd0f207d.tar.gz
enigma-fork-029f65d110279288f4cad7fb7cfaa33efd0f207d.tar.xz
enigma-fork-029f65d110279288f4cad7fb7cfaa33efd0f207d.zip
Show public/protected/private access on field/method/constructor references
Diffstat (limited to 'src/cuchaz/enigma/analysis/Access.java')
-rw-r--r--src/cuchaz/enigma/analysis/Access.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/analysis/Access.java b/src/cuchaz/enigma/analysis/Access.java
new file mode 100644
index 0000000..e35bb21
--- /dev/null
+++ b/src/cuchaz/enigma/analysis/Access.java
@@ -0,0 +1,51 @@
1/*******************************************************************************
2 * Copyright (c) 2014 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Public License v3.0
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/gpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11package cuchaz.enigma.analysis;
12
13import java.lang.reflect.Modifier;
14
15import javassist.CtBehavior;
16import javassist.CtField;
17
18public enum Access
19{
20 Public,
21 Protected,
22 Private;
23
24 public static Access get( CtBehavior behavior )
25 {
26 return get( behavior.getModifiers() );
27 }
28
29 public static Access get( CtField field )
30 {
31 return get( field.getModifiers() );
32 }
33
34 public static Access get( int modifiers )
35 {
36 if( Modifier.isPublic( modifiers ) )
37 {
38 return Public;
39 }
40 else if( Modifier.isProtected( modifiers ) )
41 {
42 return Protected;
43 }
44 else if( Modifier.isPrivate( modifiers ) )
45 {
46 return Private;
47 }
48 // assume public by default
49 return Public;
50 }
51} \ No newline at end of file