1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package io.earcam.instrumental.module.osgi;
20
21 import static io.earcam.instrumental.module.osgi.BundleManifestHeaders.*;
22 import static java.util.Collections.emptyList;
23
24 import java.util.List;
25 import java.util.Map;
26 import java.util.jar.Attributes.Name;
27
28 import javax.annotation.Nullable;
29
30 import io.earcam.instrumental.module.manifest.ManifestInfo;
31
32
33
34
35
36
37
38 public interface BundleInfo extends ManifestInfo {
39
40
41
42
43
44
45
46
47 public abstract Map<Name, List<Clause>> allHeaderClauses();
48
49
50
51
52
53
54
55
56
57 public abstract BundleInfoBuilder deconstruct();
58
59
60
61
62
63
64
65
66
67 public default List<Clause> exportPackage()
68 {
69 return allHeaderClauses().getOrDefault(EXPORT_PACKAGE.header(), emptyList());
70 }
71
72
73
74
75
76
77
78
79
80 public default List<Clause> importPackage()
81 {
82 return allHeaderClauses().getOrDefault(IMPORT_PACKAGE.header(), emptyList());
83 }
84
85
86
87
88
89
90
91
92
93 public default List<Clause> dynamicImportPackage()
94 {
95 return allHeaderClauses().getOrDefault(DYNAMICIMPORT_PACKAGE.header(), emptyList());
96 }
97
98
99
100
101
102
103
104
105
106 public default Clause symbolicName()
107 {
108 return allHeaderClauses().get(BUNDLE_SYMBOLICNAME.header()).get(0);
109 }
110
111
112
113
114
115
116
117
118
119 public default Clause fragmentHost()
120 {
121 return allHeaderClauses().get(FRAGMENT_HOST.header()).get(0);
122 }
123
124
125
126
127
128
129
130
131
132 public default @Nullable String activator()
133 {
134 List<Clause> header = allHeaderClauses().get(BUNDLE_ACTIVATOR.header());
135 return (header == null) ? null : header.get(0).uniqueNames().first();
136 }
137 }