blob: 82ca6692c339ff84260d20fa418ec3ed9df791e6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/*******************************************************************************
* Copyright (c) 2015 Jeff Martin.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public
* License v3.0 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Contributors:
* Jeff Martin - initial API and implementation
******************************************************************************/
package cuchaz.enigma.analysis;
import cuchaz.enigma.translation.representation.AccessFlags;
import java.lang.reflect.Modifier;
public enum Access {
PUBLIC, PROTECTED, PACKAGE, PRIVATE;
public static Access get(AccessFlags flags) {
return get(flags.getFlags());
}
public static Access get(int modifiers) {
boolean isPublic = Modifier.isPublic(modifiers);
boolean isProtected = Modifier.isProtected(modifiers);
boolean isPrivate = Modifier.isPrivate(modifiers);
if (isPublic && !isProtected && !isPrivate) {
return PUBLIC;
} else if (!isPublic && isProtected && !isPrivate) {
return PROTECTED;
} else if (!isPublic && !isProtected && isPrivate) {
return PRIVATE;
} else if (!isPublic && !isProtected && !isPrivate) {
return PACKAGE;
}
// assume public by default
return PUBLIC;
}
}
|