1 | /*- | |
2 | * #%L | |
3 | * io.earcam.utilitarian.site.sitemap | |
4 | * %% | |
5 | * Copyright (C) 2017 earcam | |
6 | * %% | |
7 | * SPDX-License-Identifier: (BSD-3-Clause OR EPL-1.0 OR Apache-2.0 OR MIT) | |
8 | * | |
9 | * You <b>must</b> choose to accept, in full - any individual or combination of | |
10 | * the following licenses: | |
11 | * <ul> | |
12 | * <li><a href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</a></li> | |
13 | * <li><a href="https://www.eclipse.org/legal/epl-v10.html">EPL-1.0</a></li> | |
14 | * <li><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></li> | |
15 | * <li><a href="https://opensource.org/licenses/MIT">MIT</a></li> | |
16 | * </ul> | |
17 | * #L% | |
18 | */ | |
19 | package io.earcam.utilitarian.site.sitemap; | |
20 | ||
21 | import java.io.IOException; | |
22 | import java.net.URI; | |
23 | import java.nio.file.Path; | |
24 | import java.nio.file.Paths; | |
25 | import java.util.Map; | |
26 | import java.util.function.Consumer; | |
27 | import java.util.stream.Stream; | |
28 | ||
29 | import javax.annotation.concurrent.NotThreadSafe; | |
30 | ||
31 | @NotThreadSafe | |
32 | public final class SitemapIndex extends AbstractSitemap { | |
33 | ||
34 | public static final String NAME_SITEMAP_INDEX = "sitemapindex"; | |
35 | ||
36 | private static final String TAG_SITEMAP = "sitemap"; | |
37 | ||
38 | private static final String HEAD = "<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"; | |
39 | ||
40 | private static final String TAIL = "</sitemapindex>"; | |
41 | ||
42 | private SitemapParameters currentParameters; | |
43 | ||
44 | private URI targetUri; | |
45 | ||
46 | ||
47 | public SitemapIndex(SitemapParameters parameters, Consumer<Path> generatedFileRecorder) | |
48 | { | |
49 | super(parameters, HEAD, TAG_SITEMAP, TAIL, generatedFileRecorder); | |
50 | } | |
51 | ||
52 | ||
53 | public void accept(Stream<Map.Entry<SitemapParameters, Stream<String>>> sitemaps) throws IOException | |
54 | { | |
55 | Stream<Path> paths = sitemaps.sequential() | |
56 | .flatMap(this::perGroup); | |
57 | ||
58 |
1
1. accept : removed call to io/earcam/utilitarian/site/sitemap/AbstractSitemap::process → KILLED |
super.process(paths); |
59 | } | |
60 | ||
61 | ||
62 | private Stream<Path> perGroup(Map.Entry<SitemapParameters, Stream<String>> sitemaps) | |
63 | { | |
64 | this.currentParameters = sitemaps.getKey(); | |
65 | this.targetUri = currentParameters.targetDir.toUri(); | |
66 | ||
67 |
2
1. lambda$perGroup$0 : mutated return of Object value for io/earcam/utilitarian/site/sitemap/SitemapIndex::lambda$perGroup$0 to ( if (x != null) null else throw new RuntimeException ) → KILLED 2. perGroup : mutated return of Object value for io/earcam/utilitarian/site/sitemap/SitemapIndex::perGroup to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return sitemaps.getValue().map(Paths::get); |
68 | } | |
69 | ||
70 | ||
71 | @Override | |
72 | protected Path filename() | |
73 | { | |
74 |
2
1. filename : Replaced integer addition with subtraction → KILLED 2. filename : mutated return of Object value for io/earcam/utilitarian/site/sitemap/SitemapIndex::filename to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return filename(parameters, NAME_SITEMAP_INDEX + (++indexFileSuffix)); |
75 | } | |
76 | ||
77 | ||
78 | @Override | |
79 | protected String createUrl(Path sitemapXml) throws IOException | |
80 | { | |
81 | URI uri = targetUri.relativize(sitemapXml.toUri()); | |
82 |
1
1. createUrl : mutated return of Object value for io/earcam/utilitarian/site/sitemap/SitemapIndex::createUrl to ( if (x != null) null else throw new RuntimeException ) → KILLED |
return currentParameters.base.resolve(uri).toString(); |
83 | } | |
84 | } | |
Mutations | ||
58 |
1.1 |
|
67 |
1.1 2.2 |
|
74 |
1.1 2.2 |
|
82 |
1.1 |