1 | package fr.sii.ogham.core.builder.template; | |
2 | ||
3 | import static fr.sii.ogham.core.util.BuilderUtils.instantiateBuilder; | |
4 | ||
5 | import java.util.ArrayList; | |
6 | import java.util.List; | |
7 | ||
8 | import org.slf4j.Logger; | |
9 | import org.slf4j.LoggerFactory; | |
10 | ||
11 | import fr.sii.ogham.core.builder.Builder; | |
12 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilder; | |
13 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper; | |
14 | import fr.sii.ogham.core.builder.configurer.Configurer; | |
15 | import fr.sii.ogham.core.builder.context.BuildContext; | |
16 | import fr.sii.ogham.core.builder.env.EnvironmentBuilder; | |
17 | import fr.sii.ogham.core.builder.priority.ImplementationPriorityProvider; | |
18 | import fr.sii.ogham.core.builder.priority.PriorityProvider; | |
19 | import fr.sii.ogham.core.exception.builder.BuildException; | |
20 | import fr.sii.ogham.core.message.content.MultiTemplateContent; | |
21 | import fr.sii.ogham.core.message.content.Variant; | |
22 | import fr.sii.ogham.core.template.detector.FixedEngineDetector; | |
23 | import fr.sii.ogham.core.template.detector.TemplateEngineDetector; | |
24 | import fr.sii.ogham.core.template.parser.AutoDetectTemplateParser; | |
25 | import fr.sii.ogham.core.template.parser.AutoDetectTemplateParser.TemplateImplementation; | |
26 | import fr.sii.ogham.core.template.parser.TemplateParser; | |
27 | import fr.sii.ogham.core.util.PriorizedList; | |
28 | import fr.sii.ogham.template.common.adapter.FailIfNotFoundVariantResolver; | |
29 | import fr.sii.ogham.template.common.adapter.FailIfNotFoundWithTestedPathsVariantResolver; | |
30 | import fr.sii.ogham.template.common.adapter.FirstExistingResourceVariantResolver; | |
31 | import fr.sii.ogham.template.common.adapter.NullVariantResolver; | |
32 | import fr.sii.ogham.template.common.adapter.VariantResolver; | |
33 | ||
34 | /** | |
35 | * Helps to configure a {@link TemplateParser} builder. | |
36 | * | |
37 | * <p> | |
38 | * It registers and uses {@link Builder}s to instantiate and configure | |
39 | * {@link TemplateParser} specialized implementations. | |
40 | * </p> | |
41 | * | |
42 | * <p> | |
43 | * It also configures how to handle missing variant (either fail or do nothing). | |
44 | * </p> | |
45 | * | |
46 | * @author Aurélien Baudet | |
47 | * | |
48 | * @param <P> | |
49 | * the type of the parent builder used by custom | |
50 | * {@link TemplateParser} {@link Builder} | |
51 | */ | |
52 | public class TemplateBuilderHelper<P> { | |
53 | private static final Logger LOG = LoggerFactory.getLogger(TemplateBuilderHelper.class); | |
54 | ||
55 | private final P parent; | |
56 | private final List<Builder<? extends TemplateParser>> templateBuilders; | |
57 | private final BuildContext buildContext; | |
58 | private final ConfigurationValueBuilderHelper<TemplateBuilderHelper<P>, Boolean> missingVariantFailValueBuilder; | |
59 | private final ConfigurationValueBuilderHelper<TemplateBuilderHelper<P>, Boolean> listPossiblePathsValueBuilder; | |
60 | private final PriorityProvider<TemplateParser> priorityProvider; | |
61 | private VariantResolver missingResolver; | |
62 | ||
63 | /** | |
64 | * Initializes the builder with a parent builder. The parent builder is used | |
65 | * when calling and() method of any registered {@link TemplateParser} | |
66 | * {@link Builder}. The {@link EnvironmentBuilder} is used to evaluate | |
67 | * properties at build time (used by {@link TemplateParser} | |
68 | * {@link Builder}s). | |
69 | * | |
70 | * @param parent | |
71 | * the parent builder | |
72 | * @param buildContext | |
73 | * for registering instances and property evaluation | |
74 | */ | |
75 | public TemplateBuilderHelper(P parent, BuildContext buildContext) { | |
76 | super(); | |
77 | this.parent = parent; | |
78 | this.buildContext = buildContext; | |
79 | templateBuilders = new ArrayList<>(); | |
80 | missingVariantFailValueBuilder = buildContext.newConfigurationValueBuilder(this, Boolean.class); | |
81 | listPossiblePathsValueBuilder = buildContext.newConfigurationValueBuilder(this, Boolean.class); | |
82 | priorityProvider = new ImplementationPriorityProvider<>(buildContext); | |
83 | } | |
84 | ||
85 | /** | |
86 | * Indicates if some {@link TemplateParser} {@link Builder}s have been | |
87 | * registered | |
88 | * | |
89 | * @return true if at least one builder has been registered | |
90 | */ | |
91 | public boolean hasRegisteredTemplates() { | |
92 |
15
1. hasRegisteredTemplates : replaced boolean return with true for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::hasRegisteredTemplates → SURVIVED 2. hasRegisteredTemplates : replaced boolean return with true for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::hasRegisteredTemplates → NO_COVERAGE 3. hasRegisteredTemplates : negated conditional → NO_COVERAGE 4. hasRegisteredTemplates : replaced boolean return with true for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::hasRegisteredTemplates → KILLED 5. hasRegisteredTemplates : replaced boolean return with true for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::hasRegisteredTemplates → KILLED 6. hasRegisteredTemplates : replaced boolean return with true for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::hasRegisteredTemplates → KILLED 7. hasRegisteredTemplates : replaced boolean return with true for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::hasRegisteredTemplates → KILLED 8. hasRegisteredTemplates : replaced boolean return with true for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::hasRegisteredTemplates → KILLED 9. hasRegisteredTemplates : negated conditional → KILLED 10. hasRegisteredTemplates : negated conditional → KILLED 11. hasRegisteredTemplates : negated conditional → KILLED 12. hasRegisteredTemplates : negated conditional → KILLED 13. hasRegisteredTemplates : negated conditional → KILLED 14. hasRegisteredTemplates : negated conditional → KILLED 15. hasRegisteredTemplates : negated conditional → KILLED |
return !templateBuilders.isEmpty(); |
93 | } | |
94 | ||
95 | /** | |
96 | * If a variant is missing, then force to fail. | |
97 | * | |
98 | * <p> | |
99 | * This may be useful if you want for example to always provide a text | |
100 | * fallback when using an html template. So if a client can't read the html | |
101 | * version, the fallback version will still always be readable. So to avoid | |
102 | * forgetting to write text template, set this to true. | |
103 | * </p> | |
104 | * | |
105 | * <p> | |
106 | * The value set using this method takes precedence over any property and | |
107 | * default value configured using {@link #failIfMissingVariant()}. | |
108 | * | |
109 | * <pre> | |
110 | * .failIfMissingVariant(false) | |
111 | * .failIfMissingVariant() | |
112 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
113 | * .defaultValue(true) | |
114 | * </pre> | |
115 | * | |
116 | * <pre> | |
117 | * .failIfMissingVariant(false) | |
118 | * .failIfMissingVariant() | |
119 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
120 | * .defaultValue(true) | |
121 | * </pre> | |
122 | * | |
123 | * In both cases, {@code failIfMissingVariant(false)} is used. | |
124 | * | |
125 | * <p> | |
126 | * If this method is called several times, only the last value is used. | |
127 | * | |
128 | * <p> | |
129 | * If {@code null} value is set, it is like not setting a value at all. The | |
130 | * property/default value configuration is applied. | |
131 | * | |
132 | * @param fail | |
133 | * fail if a variant is missing | |
134 | * @return this instance for fluent chaining | |
135 | */ | |
136 | public TemplateBuilderHelper<P> failIfMissingVariant(Boolean fail) { | |
137 |
1
1. failIfMissingVariant : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE |
missingVariantFailValueBuilder.setValue(fail); |
138 |
1
1. failIfMissingVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::failIfMissingVariant → NO_COVERAGE |
return this; |
139 | } | |
140 | ||
141 | /** | |
142 | * If a variant is missing, then force to fail. | |
143 | * | |
144 | * <p> | |
145 | * This may be useful if you want for example to always provide a text | |
146 | * fallback when using an html template. So if a client can't read the html | |
147 | * version, the fallback version will still always be readable. So to avoid | |
148 | * forgetting to write text template, set this to true. | |
149 | * </p> | |
150 | * | |
151 | * <p> | |
152 | * This method is mainly used by {@link Configurer}s to register some | |
153 | * property keys and/or a default value. The aim is to let developer be able | |
154 | * to externalize its configuration (using system properties, configuration | |
155 | * file or anything else). If the developer doesn't configure any value for | |
156 | * the registered properties, the default value is used (if set). | |
157 | * | |
158 | * <pre> | |
159 | * .failIfMissingVariant() | |
160 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
161 | * .defaultValue(true) | |
162 | * </pre> | |
163 | * | |
164 | * <p> | |
165 | * Non-null value set using {@link #failIfMissingVariant(Boolean)} takes | |
166 | * precedence over property values and default value. | |
167 | * | |
168 | * <pre> | |
169 | * .failIfMissingVariant(false) | |
170 | * .failIfMissingVariant() | |
171 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
172 | * .defaultValue(true) | |
173 | * </pre> | |
174 | * | |
175 | * The value {@code false} is used regardless of the value of the properties | |
176 | * and default value. | |
177 | * | |
178 | * <p> | |
179 | * See {@link ConfigurationValueBuilder} for more information. | |
180 | * | |
181 | * | |
182 | * @return the builder to configure property keys/default value | |
183 | */ | |
184 | public ConfigurationValueBuilder<TemplateBuilderHelper<P>, Boolean> failIfMissingVariant() { | |
185 |
8
1. failIfMissingVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::failIfMissingVariant → NO_COVERAGE 2. failIfMissingVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::failIfMissingVariant → KILLED 3. failIfMissingVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::failIfMissingVariant → KILLED 4. failIfMissingVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::failIfMissingVariant → KILLED 5. failIfMissingVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::failIfMissingVariant → KILLED 6. failIfMissingVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::failIfMissingVariant → KILLED 7. failIfMissingVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::failIfMissingVariant → KILLED 8. failIfMissingVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::failIfMissingVariant → KILLED |
return missingVariantFailValueBuilder; |
186 | } | |
187 | ||
188 | /** | |
189 | * When {@link #failIfMissingVariant()} is enabled, also indicate which | |
190 | * paths were tried in order to help debugging why a variant was not found. | |
191 | * | |
192 | * <p> | |
193 | * The value set using this method takes precedence over any property and | |
194 | * default value configured using {@link #listPossiblePaths()}. | |
195 | * | |
196 | * <pre> | |
197 | * .listPossiblePaths(true) | |
198 | * .listPossiblePaths() | |
199 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
200 | * .defaultValue(false) | |
201 | * </pre> | |
202 | * | |
203 | * <pre> | |
204 | * .listPossiblePaths(true) | |
205 | * .listPossiblePaths() | |
206 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
207 | * .defaultValue(false) | |
208 | * </pre> | |
209 | * | |
210 | * In both cases, {@code listPossiblePaths(true)} is used. | |
211 | * | |
212 | * <p> | |
213 | * If this method is called several times, only the last value is used. | |
214 | * | |
215 | * <p> | |
216 | * If {@code null} value is set, it is like not setting a value at all. The | |
217 | * property/default value configuration is applied. | |
218 | * | |
219 | * @param enable | |
220 | * enable/disable tracking of possible paths for template | |
221 | * variants | |
222 | * @return this instance for fluent chaining | |
223 | */ | |
224 | public TemplateBuilderHelper<P> listPossiblePaths(Boolean enable) { | |
225 |
1
1. listPossiblePaths : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE |
listPossiblePathsValueBuilder.setValue(enable); |
226 |
1
1. listPossiblePaths : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::listPossiblePaths → NO_COVERAGE |
return this; |
227 | } | |
228 | ||
229 | /** | |
230 | * When {@link #failIfMissingVariant()} is enabled, also indicate which | |
231 | * paths were tried in order to help debugging why a variant was not found. | |
232 | * | |
233 | * <p> | |
234 | * This method is mainly used by {@link Configurer}s to register some | |
235 | * property keys and/or a default value. The aim is to let developer be able | |
236 | * to externalize its configuration (using system properties, configuration | |
237 | * file or anything else). If the developer doesn't configure any value for | |
238 | * the registered properties, the default value is used (if set). | |
239 | * | |
240 | * <pre> | |
241 | * .listPossiblePaths() | |
242 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
243 | * .defaultValue(false) | |
244 | * </pre> | |
245 | * | |
246 | * <p> | |
247 | * Non-null value set using {@link #listPossiblePaths(Boolean)} takes | |
248 | * precedence over property values and default value. | |
249 | * | |
250 | * <pre> | |
251 | * .listPossiblePaths(true) | |
252 | * .listPossiblePaths() | |
253 | * .properties("${custom.property.high-priority}", "${custom.property.low-priority}") | |
254 | * .defaultValue(false) | |
255 | * </pre> | |
256 | * | |
257 | * The value {@code true} is used regardless of the value of the properties | |
258 | * and default value. | |
259 | * | |
260 | * <p> | |
261 | * See {@link ConfigurationValueBuilder} for more information. | |
262 | * | |
263 | * | |
264 | * @return the builder to configure property keys/default value | |
265 | */ | |
266 | public ConfigurationValueBuilder<TemplateBuilderHelper<P>, Boolean> listPossiblePaths() { | |
267 |
8
1. listPossiblePaths : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::listPossiblePaths → NO_COVERAGE 2. listPossiblePaths : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::listPossiblePaths → KILLED 3. listPossiblePaths : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::listPossiblePaths → KILLED 4. listPossiblePaths : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::listPossiblePaths → KILLED 5. listPossiblePaths : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::listPossiblePaths → KILLED 6. listPossiblePaths : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::listPossiblePaths → KILLED 7. listPossiblePaths : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::listPossiblePaths → KILLED 8. listPossiblePaths : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::listPossiblePaths → KILLED |
return listPossiblePathsValueBuilder; |
268 | } | |
269 | ||
270 | /** | |
271 | * Provide custom resolver that will handle a missing variant. | |
272 | * | |
273 | * @param resolver | |
274 | * the custom resolver | |
275 | */ | |
276 | public void missingVariant(VariantResolver resolver) { | |
277 | this.missingResolver = resolver; | |
278 | } | |
279 | ||
280 | /** | |
281 | * Registers and configures a {@link TemplateParser} through a dedicated | |
282 | * builder. | |
283 | * | |
284 | * For example: | |
285 | * | |
286 | * <pre> | |
287 | * .register(ThymeleafEmailBuilder.class) | |
288 | * .detector(new ThymeleafEngineDetector()); | |
289 | * </pre> | |
290 | * | |
291 | * <p> | |
292 | * Your {@link Builder} may implement {@link VariantBuilder} to handle | |
293 | * template {@link Variant}s (used for {@link MultiTemplateContent} that | |
294 | * provide a single path to templates with different extensions for | |
295 | * example). | |
296 | * </p> | |
297 | * | |
298 | * <p> | |
299 | * Your {@link Builder} may also implement {@link DetectorBuilder} in order | |
300 | * to indicate which kind of templates your {@link TemplateParser} is able | |
301 | * to parse. If your template parse is able to parse any template file you | |
302 | * are using, you may not need to implement {@link DetectorBuilder}. | |
303 | * </p> | |
304 | * | |
305 | * <p> | |
306 | * In order to be able to keep chaining, you builder instance may provide a | |
307 | * constructor with two arguments: | |
308 | * <ul> | |
309 | * <li>The type of the parent builder ({@code <P>})</li> | |
310 | * <li>The {@link EnvironmentBuilder} instance</li> | |
311 | * </ul> | |
312 | * If you don't care about chaining, just provide a default constructor. | |
313 | * | |
314 | * @param builderClass | |
315 | * the builder class to instantiate | |
316 | * @param <B> | |
317 | * the type of the builder | |
318 | * @return the builder to configure the implementation | |
319 | */ | |
320 | @SuppressWarnings("unchecked") | |
321 | public <B extends Builder<? extends TemplateParser>> B register(Class<B> builderClass) { | |
322 | // if already registered => provide same instance | |
323 | for (Builder<? extends TemplateParser> builder : templateBuilders) { | |
324 |
5
1. register : negated conditional → NO_COVERAGE 2. register : negated conditional → KILLED 3. register : negated conditional → KILLED 4. register : negated conditional → KILLED 5. register : negated conditional → KILLED |
if (builderClass.isAssignableFrom(builder.getClass())) { |
325 |
4
1. register : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::register → NO_COVERAGE 2. register : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::register → KILLED 3. register : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::register → KILLED 4. register : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::register → KILLED |
return (B) builder; |
326 | } | |
327 | } | |
328 | // create the builder instance | |
329 | B builder = instantiateBuilder(builderClass, parent, buildContext); | |
330 | templateBuilders.add(builder); | |
331 |
5
1. register : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::register → NO_COVERAGE 2. register : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::register → KILLED 3. register : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::register → KILLED 4. register : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::register → KILLED 5. register : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::register → KILLED |
return builder; |
332 | } | |
333 | ||
334 | /** | |
335 | * Build the template parser according to options previously enabled. If | |
336 | * only one template engine has been activated then the parser will be this | |
337 | * template engine parser. If there are several activated engines, then the | |
338 | * builder will generate an {@link AutoDetectTemplateParser}. This kind of | |
339 | * parser is able to detect which parser to use according to the provided | |
340 | * template at runtime. The auto-detection is delegated to each defined | |
341 | * {@link TemplateEngineDetector} associated with each engine. | |
342 | * | |
343 | * @return the template parser instance | |
344 | * @throws BuildException | |
345 | * when template parser couldn't be initialized | |
346 | */ | |
347 | public TemplateParser buildTemplateParser() { | |
348 | // TODO: handle enable? | |
349 | List<TemplateImplementation> impls = buildTemplateParserImpls(); | |
350 |
5
1. buildTemplateParser : negated conditional → NO_COVERAGE 2. buildTemplateParser : negated conditional → KILLED 3. buildTemplateParser : negated conditional → KILLED 4. buildTemplateParser : negated conditional → KILLED 5. buildTemplateParser : negated conditional → KILLED |
if (impls.isEmpty()) { |
351 | // if no template parser available => exception | |
352 | throw new BuildException("No parser available. Either disable template features or register a template engine"); | |
353 | } | |
354 |
5
1. buildTemplateParser : negated conditional → SURVIVED 2. buildTemplateParser : negated conditional → NO_COVERAGE 3. buildTemplateParser : negated conditional → KILLED 4. buildTemplateParser : negated conditional → KILLED 5. buildTemplateParser : negated conditional → KILLED |
if (impls.size() == 1) { |
355 | // if no detector defined or only one available parser => do not use | |
356 | // auto detection | |
357 | TemplateParser parser = impls.get(0).getParser(); | |
358 | LOG.info("Using single template engine: {}", parser); | |
359 |
3
1. buildTemplateParser : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParser → NO_COVERAGE 2. buildTemplateParser : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParser → KILLED 3. buildTemplateParser : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParser → KILLED |
return parser; |
360 | } | |
361 | LOG.info("Using auto detection mechanism"); | |
362 | LOG.debug("Auto detection mechanisms: {}", impls); | |
363 |
5
1. buildTemplateParser : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParser → NO_COVERAGE 2. buildTemplateParser : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParser → KILLED 3. buildTemplateParser : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParser → KILLED 4. buildTemplateParser : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParser → KILLED 5. buildTemplateParser : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParser → KILLED |
return buildContext.register(new AutoDetectTemplateParser(impls)); |
364 | } | |
365 | ||
366 | /** | |
367 | * Instantiates and configures the variant resolution. Variant resolution is | |
368 | * a chain of resolvers. The first resolver that is able to resolve a | |
369 | * variant is used. If no resolver is able to resolve a variant, it uses the | |
370 | * default variant resolver (see {@link #failIfMissingVariant(Boolean)} and | |
371 | * {@link #missingVariant(VariantResolver)}). | |
372 | * | |
373 | * @return the variant resolver | |
374 | */ | |
375 | public VariantResolver buildVariant() { | |
376 | FirstExistingResourceVariantResolver variantResolver = buildContext.register(new FirstExistingResourceVariantResolver(buildDefaultVariantResolver())); | |
377 | for (Builder<? extends TemplateParser> builder : templateBuilders) { | |
378 |
3
1. buildVariant : negated conditional → NO_COVERAGE 2. buildVariant : negated conditional → SURVIVED 3. buildVariant : negated conditional → KILLED |
if (builder instanceof VariantBuilder) { |
379 | variantResolver.addVariantResolver(((VariantBuilder<?>) builder).buildVariant()); | |
380 | } | |
381 | } | |
382 |
3
1. buildVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildVariant → SURVIVED 2. buildVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildVariant → NO_COVERAGE 3. buildVariant : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildVariant → KILLED |
return variantResolver; |
383 | } | |
384 | ||
385 | @SuppressWarnings("squid:S5411") | |
386 | private VariantResolver buildDefaultVariantResolver() { | |
387 |
3
1. buildDefaultVariantResolver : negated conditional → NO_COVERAGE 2. buildDefaultVariantResolver : negated conditional → SURVIVED 3. buildDefaultVariantResolver : negated conditional → KILLED |
if (missingResolver != null) { |
388 |
1
1. buildDefaultVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildDefaultVariantResolver → NO_COVERAGE |
return missingResolver; |
389 | } | |
390 |
3
1. buildDefaultVariantResolver : negated conditional → NO_COVERAGE 2. buildDefaultVariantResolver : negated conditional → SURVIVED 3. buildDefaultVariantResolver : negated conditional → KILLED |
if (missingVariantFailValueBuilder.getValue(false)) { |
391 |
4
1. buildDefaultVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildDefaultVariantResolver → NO_COVERAGE 2. buildDefaultVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildDefaultVariantResolver → SURVIVED 3. buildDefaultVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildDefaultVariantResolver → TIMED_OUT 4. buildDefaultVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildDefaultVariantResolver → KILLED |
return buildFailingVariantResolver(); |
392 | } | |
393 |
2
1. buildDefaultVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildDefaultVariantResolver → NO_COVERAGE 2. buildDefaultVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildDefaultVariantResolver → KILLED |
return buildContext.register(new NullVariantResolver()); |
394 | } | |
395 | ||
396 | @SuppressWarnings("squid:S5411") | |
397 | private VariantResolver buildFailingVariantResolver() { | |
398 |
3
1. buildFailingVariantResolver : negated conditional → SURVIVED 2. buildFailingVariantResolver : negated conditional → NO_COVERAGE 3. buildFailingVariantResolver : negated conditional → KILLED |
if (!listPossiblePathsValueBuilder.getValue(false)) { |
399 |
1
1. buildFailingVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildFailingVariantResolver → NO_COVERAGE |
return buildContext.register(new FailIfNotFoundVariantResolver()); |
400 | } | |
401 | FailIfNotFoundWithTestedPathsVariantResolver failResolver = new FailIfNotFoundWithTestedPathsVariantResolver(); | |
402 | for (Builder<? extends TemplateParser> builder : templateBuilders) { | |
403 |
3
1. buildFailingVariantResolver : negated conditional → NO_COVERAGE 2. buildFailingVariantResolver : negated conditional → SURVIVED 3. buildFailingVariantResolver : negated conditional → KILLED |
if (builder instanceof VariantBuilder) { |
404 | failResolver.addVariantResolver(((VariantBuilder<?>) builder).buildVariant()); | |
405 | } | |
406 | } | |
407 |
3
1. buildFailingVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildFailingVariantResolver → NO_COVERAGE 2. buildFailingVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildFailingVariantResolver → SURVIVED 3. buildFailingVariantResolver : replaced return value with null for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildFailingVariantResolver → KILLED |
return buildContext.register(failResolver); |
408 | } | |
409 | ||
410 | private List<TemplateImplementation> buildTemplateParserImpls() { | |
411 | PriorizedList<TemplateImplementation> impls = new PriorizedList<>(); | |
412 | for (Builder<? extends TemplateParser> builder : templateBuilders) { | |
413 | TemplateEngineDetector detector; | |
414 |
5
1. buildTemplateParserImpls : negated conditional → NO_COVERAGE 2. buildTemplateParserImpls : negated conditional → KILLED 3. buildTemplateParserImpls : negated conditional → KILLED 4. buildTemplateParserImpls : negated conditional → KILLED 5. buildTemplateParserImpls : negated conditional → KILLED |
if (builder instanceof DetectorBuilder) { |
415 | detector = ((DetectorBuilder<?>) builder).buildDetector(); | |
416 | } else { | |
417 | detector = buildContext.register(new FixedEngineDetector(true)); | |
418 | } | |
419 | TemplateParser templateParser = builder.build(); | |
420 | impls.register(new TemplateImplementation(detector, templateParser), priorityProvider.provide(templateParser)); | |
421 | } | |
422 |
5
1. buildTemplateParserImpls : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParserImpls → NO_COVERAGE 2. buildTemplateParserImpls : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParserImpls → KILLED 3. buildTemplateParserImpls : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParserImpls → KILLED 4. buildTemplateParserImpls : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParserImpls → KILLED 5. buildTemplateParserImpls : replaced return value with Collections.emptyList for fr/sii/ogham/core/builder/template/TemplateBuilderHelper::buildTemplateParserImpls → KILLED |
return impls.getOrdered(); |
423 | } | |
424 | ||
425 | } | |
Mutations | ||
92 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 13.13 14.14 15.15 |
|
137 |
1.1 |
|
138 |
1.1 |
|
185 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
225 |
1.1 |
|
226 |
1.1 |
|
267 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
324 |
1.1 2.2 3.3 4.4 5.5 |
|
325 |
1.1 2.2 3.3 4.4 |
|
331 |
1.1 2.2 3.3 4.4 5.5 |
|
350 |
1.1 2.2 3.3 4.4 5.5 |
|
354 |
1.1 2.2 3.3 4.4 5.5 |
|
359 |
1.1 2.2 3.3 |
|
363 |
1.1 2.2 3.3 4.4 5.5 |
|
378 |
1.1 2.2 3.3 |
|
382 |
1.1 2.2 3.3 |
|
387 |
1.1 2.2 3.3 |
|
388 |
1.1 |
|
390 |
1.1 2.2 3.3 |
|
391 |
1.1 2.2 3.3 4.4 |
|
393 |
1.1 2.2 |
|
398 |
1.1 2.2 3.3 |
|
399 |
1.1 |
|
403 |
1.1 2.2 3.3 |
|
407 |
1.1 2.2 3.3 |
|
414 |
1.1 2.2 3.3 4.4 5.5 |
|
422 |
1.1 2.2 3.3 4.4 5.5 |