7
7
import com .github .lombrozo .xnav .Filter ;
8
8
import com .github .lombrozo .xnav .Xnav ;
9
9
import com .jcabi .log .Logger ;
10
- import java .io .FileNotFoundException ;
11
10
import java .io .IOException ;
12
11
import java .nio .file .Path ;
13
12
import java .util .Collection ;
16
15
import java .util .stream .Stream ;
17
16
import org .apache .maven .plugins .annotations .LifecyclePhase ;
18
17
import org .apache .maven .plugins .annotations .Mojo ;
19
- import org .cactoos .iterable .Filtered ;
20
18
import org .cactoos .iterable .IterableOf ;
21
19
import org .cactoos .iterable .Mapped ;
22
20
import org .cactoos .list .ListOf ;
@@ -89,9 +87,7 @@ private void probe() throws IOException {
89
87
continue ;
90
88
}
91
89
++count ;
92
- this .scopedTojos ()
93
- .add (object )
94
- .withDiscoveredAt (src );
90
+ this .scopedTojos ().add (object ).withDiscoveredAt (src );
95
91
probed .add (object );
96
92
}
97
93
tojo .withProbed (count );
@@ -123,17 +119,13 @@ private void probe() throws IOException {
123
119
*
124
120
* @param file The .xmir file
125
121
* @return List of foreign objects found
126
- * @throws FileNotFoundException If not found
127
122
*/
128
- private Collection <String > probes (final Path file ) throws FileNotFoundException {
123
+ private Collection <String > probes (final Path file ) {
129
124
final long start = System .currentTimeMillis ();
130
125
final Collection <String > objects = new ListOf <>(
131
126
new Mapped <>(
132
127
ProbeMojo ::noPrefix ,
133
- new Filtered <>(
134
- obj -> !obj .isEmpty (),
135
- ProbeMojo .probeMetas (file )
136
- )
128
+ ProbeMojo .metas (file )
137
129
).iterator ()
138
130
);
139
131
if (objects .isEmpty ()) {
@@ -151,12 +143,13 @@ private Collection<String> probes(final Path file) throws FileNotFoundException
151
143
}
152
144
153
145
/**
154
- * Return probe metas.
155
- * The equivalent xpath is: "/program/metas/meta[head/text() = 'probe']/tail/text()"
146
+ * Return metas for probing.
147
+ * The equivalent xpath is:
148
+ * "/program/metas/meta[head/text()='probe' or head/text()='also']/tail[not(text()='')]/text()"
156
149
* @param file XML file
157
150
* @return Metas to probe
158
151
*/
159
- private static Iterable <String > probeMetas (final Path file ) {
152
+ private static Iterable <String > metas (final Path file ) {
160
153
return new IterableOf <>(
161
154
new Xnav (file )
162
155
.element ("program" )
@@ -170,11 +163,14 @@ private static Iterable<String> probeMetas(final Path file) {
170
163
final Optional <String > head = new Xnav (meta )
171
164
.element ("head" )
172
165
.text ();
173
- return head .isPresent () && "probe" .equals (head .get ());
166
+ return head .map (
167
+ text -> "probe" .equals (text ) || "also" .equals (text )
168
+ ).orElse (false );
174
169
}
175
170
)
176
171
)
177
172
.map (meta -> meta .element ("tail" ).text ().get ())
173
+ .filter (meta -> !meta .isEmpty ())
178
174
)
179
175
.orElse (Stream .of ())
180
176
.iterator ()
0 commit comments