1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.themis.xanalysis.parser.node;
18
19 import com.github.javaparser.ast.Modifier.Keyword;
20 import io.github.tonywasher.joceanus.themis.xanalysis.parser.base.ThemisXAnalysisModifierList;
21 import io.github.tonywasher.joceanus.themis.xanalysis.parser.base.ThemisXAnalysisInstance.ThemisXAnalysisNodeInstance;
22
23 import java.util.List;
24
25
26
27
28 public class ThemisXAnalysisNodeModifierList
29 implements ThemisXAnalysisModifierList {
30
31
32
33 private final List<ThemisXAnalysisNodeInstance> theModifiers;
34
35
36
37
38 public ThemisXAnalysisNodeModifierList() {
39 this(null);
40 }
41
42
43
44
45
46
47 public ThemisXAnalysisNodeModifierList(final List<ThemisXAnalysisNodeInstance> pModifiers) {
48 theModifiers = pModifiers;
49 }
50
51 @Override
52 public boolean isPublic() {
53 return isPresent(Keyword.PUBLIC);
54 }
55
56 @Override
57 public boolean isProtected() {
58 return isPresent(Keyword.PROTECTED);
59 }
60
61 @Override
62 public boolean isPrivate() {
63 return isPresent(Keyword.PRIVATE);
64 }
65
66 @Override
67 public boolean isStatic() {
68 return isPresent(Keyword.STATIC);
69 }
70
71 @Override
72 public boolean isFinal() {
73 return isPresent(Keyword.FINAL);
74 }
75
76 @Override
77 public boolean isSynchronized() {
78 return isPresent(Keyword.SYNCHRONIZED);
79 }
80
81 @Override
82 public boolean isVolatile() {
83 return isPresent(Keyword.VOLATILE);
84 }
85
86 @Override
87 public boolean isTransient() {
88 return isPresent(Keyword.TRANSIENT);
89 }
90
91 @Override
92 public boolean isTransitive() {
93 return isPresent(Keyword.TRANSITIVE);
94 }
95
96 @Override
97 public boolean isNative() {
98 return isPresent(Keyword.NATIVE);
99 }
100
101 @Override
102 public boolean isAbstract() {
103 return isPresent(Keyword.ABSTRACT);
104 }
105
106 @Override
107 public boolean isSealed() {
108 return isPresent(Keyword.SEALED);
109 }
110
111
112
113
114
115
116
117 private boolean isPresent(final Keyword pKeyword) {
118 return theModifiers.stream().map(x -> (ThemisXAnalysisNodeModifier) x)
119 .map(ThemisXAnalysisNodeModifier::getKeyword).anyMatch(pKeyword::equals);
120 }
121 }