1 | package fr.sii.ogham.template.thymeleaf.v2.configure; | |
2 | ||
3 | import static fr.sii.ogham.template.thymeleaf.common.ThymeleafConstants.DEFAULT_THYMELEAF_SMS_CONFIGURER_PRIORITY; | |
4 | ||
5 | import org.slf4j.Logger; | |
6 | import org.slf4j.LoggerFactory; | |
7 | ||
8 | import fr.sii.ogham.core.builder.MessagingBuilder; | |
9 | import fr.sii.ogham.core.builder.configurer.ConfigurerFor; | |
10 | import fr.sii.ogham.core.builder.configurer.DefaultMessagingConfigurer; | |
11 | import fr.sii.ogham.core.builder.context.BuildContext; | |
12 | import fr.sii.ogham.core.builder.resolution.ResourceResolutionBuilder; | |
13 | import fr.sii.ogham.core.util.ClasspathUtils; | |
14 | import fr.sii.ogham.template.thymeleaf.common.buider.AbstractThymeleafBuilder; | |
15 | import fr.sii.ogham.template.thymeleaf.common.configure.AbstractDefaultThymeleafSmsConfigurer; | |
16 | import fr.sii.ogham.template.thymeleaf.v2.ThymeleafV2TemplateDetector; | |
17 | import fr.sii.ogham.template.thymeleaf.v2.buider.ThymeleafV2SmsBuilder; | |
18 | ||
19 | /** | |
20 | * Default configurer for Thymeleaf template engine that is automatically | |
21 | * applied every time a {@link MessagingBuilder} instance is created through | |
22 | * {@link MessagingBuilder#standard()} or {@link MessagingBuilder#minimal()}. | |
23 | * | |
24 | * <p> | |
25 | * The configurer has a priority of 70000 in order to be applied after global | |
26 | * configurer but before any sender implementation. | |
27 | * </p> | |
28 | * | |
29 | * This configurer is applied only if {@code org.thymeleaf.TemplateEngine} is | |
30 | * present in the classpath. If not present, template engine is not registered | |
31 | * at all. | |
32 | * | |
33 | * <p> | |
34 | * This configurer inherits environment configuration (see | |
35 | * {@link BuildContext}). | |
36 | * </p> | |
37 | * <p> | |
38 | * It also copies resource resolution configuration of | |
39 | * {@link DefaultMessagingConfigurer} to inherit resource resolution lookups | |
40 | * (see {@link ResourceResolutionBuilder}). | |
41 | * </p> | |
42 | * | |
43 | * <p> | |
44 | * This configurer applies the following configuration: | |
45 | * <ul> | |
46 | * <li>Configures template prefix/suffix paths: | |
47 | * <ul> | |
48 | * <li>Uses the first property that has a value for classpath resolution prefix: | |
49 | * <ol> | |
50 | * <li>"ogham.sms.thymeleaf.classpath.path-prefix"</li> | |
51 | * <li>"ogham.sms.template.classpath.path-prefix"</li> | |
52 | * <li>"ogham.sms.thymeleaf.path-prefix"</li> | |
53 | * <li>"ogham.sms.template.path-prefix"</li> | |
54 | * <li>"ogham.template.path-prefix"</li> | |
55 | * </ol> | |
56 | * </li> | |
57 | * <li>Uses the first property that has a value for classpath resolution suffix: | |
58 | * <ol> | |
59 | * <li>"ogham.sms.thymeleaf.classpath.path-suffix"</li> | |
60 | * <li>"ogham.sms.template.classpath.path-suffix"</li> | |
61 | * <li>"ogham.sms.thymeleaf.path-suffix"</li> | |
62 | * <li>"ogham.sms.template.path-suffix"</li> | |
63 | * <li>"ogham.template.path-suffix"</li> | |
64 | * </ol> | |
65 | * </li> | |
66 | * <li>Uses the first property that has a value for file resolution prefix: | |
67 | * <ol> | |
68 | * <li>"ogham.sms.thymeleaf.file.path-prefix"</li> | |
69 | * <li>"ogham.sms.template.file.path-prefix"</li> | |
70 | * <li>"ogham.sms.thymeleaf.path-prefix"</li> | |
71 | * <li>"ogham.sms.template.path-prefix"</li> | |
72 | * <li>"ogham.template.path-prefix"</li> | |
73 | * </ol> | |
74 | * </li> | |
75 | * <li>Uses the first property that has a value for file resolution suffix: | |
76 | * <ol> | |
77 | * <li>"ogham.sms.thymeleaf.file.path-suffix"</li> | |
78 | * <li>"ogham.sms.template.file.path-suffix"</li> | |
79 | * <li>"ogham.sms.thymeleaf.path-suffix"</li> | |
80 | * <li>"ogham.sms.template.path-suffix"</li> | |
81 | * <li>"ogham.template.path-suffix"</li> | |
82 | * </ol> | |
83 | * </li> | |
84 | * </ul> | |
85 | * </li> | |
86 | * <li>Configures template detection: | |
87 | * <ul> | |
88 | * <li>Uses {@link ThymeleafV2TemplateDetector} to detect if templates are | |
89 | * parseable by Thymeleaf</li> | |
90 | * </ul> | |
91 | * </li> | |
92 | * </ul> | |
93 | * | |
94 | * @author Aurélien Baudet | |
95 | * | |
96 | */ | |
97 | public final class DefaultThymeleafV2SmsConfigurer { | |
98 | private static final Logger LOG = LoggerFactory.getLogger(DefaultThymeleafV2SmsConfigurer.class); | |
99 | ||
100 | @ConfigurerFor(targetedBuilder = { "minimal", "standard" }, priority = DEFAULT_THYMELEAF_SMS_CONFIGURER_PRIORITY) | |
101 | public static class ThymeleafV2SmsConfigurer extends AbstractDefaultThymeleafSmsConfigurer { | |
102 | public ThymeleafV2SmsConfigurer() { | |
103 | super(LOG); | |
104 | } | |
105 | ||
106 | @Override | |
107 | protected boolean canUseThymeleaf() { | |
108 |
7
1. canUseThymeleaf : replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleaf → SURVIVED 2. canUseThymeleaf : replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleaf → NO_COVERAGE 3. canUseThymeleaf : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleaf → NO_COVERAGE 4. canUseThymeleaf : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleaf → SURVIVED 5. canUseThymeleaf : replaced boolean return with false for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleaf → KILLED 6. canUseThymeleaf : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleaf → KILLED 7. canUseThymeleaf : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleaf → KILLED |
return canUseThymeleafV2(); |
109 | } | |
110 | ||
111 | @Override | |
112 | protected Class<? extends AbstractThymeleafBuilder<?, ?, ?>> getBuilderClass() { | |
113 |
2
1. getBuilderClass : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::getBuilderClass → NO_COVERAGE 2. getBuilderClass : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::getBuilderClass → KILLED |
return ThymeleafV2SmsBuilder.class; |
114 | } | |
115 | ||
116 | private static boolean canUseThymeleafV2() { | |
117 |
11
1. canUseThymeleafV2 : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleafV2 → NO_COVERAGE 2. canUseThymeleafV2 : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleafV2 → SURVIVED 3. canUseThymeleafV2 : negated conditional → SURVIVED 4. canUseThymeleafV2 : negated conditional → NO_COVERAGE 5. canUseThymeleafV2 : negated conditional → NO_COVERAGE 6. canUseThymeleafV2 : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleafV2 → KILLED 7. canUseThymeleafV2 : replaced boolean return with true for fr/sii/ogham/template/thymeleaf/v2/configure/DefaultThymeleafV2SmsConfigurer$ThymeleafV2SmsConfigurer::canUseThymeleafV2 → KILLED 8. canUseThymeleafV2 : negated conditional → KILLED 9. canUseThymeleafV2 : negated conditional → KILLED 10. canUseThymeleafV2 : negated conditional → KILLED 11. canUseThymeleafV2 : negated conditional → KILLED |
return ClasspathUtils.exists("org.thymeleaf.TemplateEngine") && !ClasspathUtils.exists("org.thymeleaf.IEngineConfiguration"); |
118 | } | |
119 | } | |
120 | ||
121 | private DefaultThymeleafV2SmsConfigurer() { | |
122 | super(); | |
123 | } | |
124 | } | |
Mutations | ||
108 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
113 |
1.1 2.2 |
|
117 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 |