| 1 | package fr.sii.ogham.template.thymeleaf.v2.buider; | |
| 2 | ||
| 3 | import org.thymeleaf.TemplateEngine; | |
| 4 | import org.thymeleaf.templateresolver.ITemplateResolver; | |
| 5 | ||
| 6 | import fr.sii.ogham.core.builder.context.BuildContext; | |
| 7 | import fr.sii.ogham.core.builder.env.EnvironmentBuilder; | |
| 8 | import fr.sii.ogham.core.template.detector.TemplateEngineDetector; | |
| 9 | import fr.sii.ogham.sms.builder.SmsBuilder; | |
| 10 | import fr.sii.ogham.template.thymeleaf.common.adapter.FileResolverAdapter; | |
| 11 | import fr.sii.ogham.template.thymeleaf.common.adapter.FirstSupportingResolverAdapter; | |
| 12 | import fr.sii.ogham.template.thymeleaf.common.adapter.TemplateResolverAdapter; | |
| 13 | import fr.sii.ogham.template.thymeleaf.common.buider.AbstractThymeleafBuilder; | |
| 14 | import fr.sii.ogham.template.thymeleaf.v2.ThymeLeafV2FirstSupportingTemplateResolver; | |
| 15 | import fr.sii.ogham.template.thymeleaf.v2.ThymeleafV2TemplateDetector; | |
| 16 | import fr.sii.ogham.template.thymeleaf.v2.adapter.FixClassPathResolverAdapter; | |
| 17 | import fr.sii.ogham.template.thymeleaf.v2.adapter.StringResolverAdapter; | |
| 18 | import fr.sii.ogham.template.thymeleaf.v2.adapter.ThymeleafV2TemplateOptionsApplier; | |
| 19 | ||
| 20 | /** | |
| 21 | * Configures parsing of templates using Thymeleaf. | |
| 22 | * | |
| 23 | * Specific resource resolution can be configured to use template prefix/suffix | |
| 24 | * paths: | |
| 25 | * | |
| 26 | * <pre> | |
| 27 | * <code> | |
| 28 | * .classpath() | |
| 29 | * .pathPrefix("email/") | |
| 30 | * .pathSuffix(".html") | |
| 31 | * .and() | |
| 32 | * .file() | |
| 33 | * .pathPrefix("/data/myapplication/templates/email") | |
| 34 | * .pathSuffix(".html") | |
| 35 | * </code> | |
| 36 | * </pre> | |
| 37 | * | |
| 38 | * You can customize default Thymeleaf {@link TemplateEngine}: | |
| 39 | * | |
| 40 | * <pre> | |
| 41 | * <code> | |
| 42 | * .engine() | |
| 43 | * .addDialect("foo", myDialect) | |
| 44 | * .addMessageResolver(myMessageResolver) | |
| 45 | * </code> | |
| 46 | * </pre> | |
| 47 | * | |
| 48 | * Or you can use a particular Thymeleaf {@link TemplateEngine}: | |
| 49 | * | |
| 50 | * <pre> | |
| 51 | * <code> | |
| 52 | * .engine(new MyTemplateEngine()) | |
| 53 | * </code> | |
| 54 | * </pre> | |
| 55 | * | |
| 56 | * @author Aurélien Baudet | |
| 57 | * | |
| 58 | */ | |
| 59 | public class ThymeleafV2SmsBuilder extends AbstractThymeleafBuilder<ThymeleafV2SmsBuilder, SmsBuilder, ThymeleafV2EngineConfigBuilder<ThymeleafV2SmsBuilder>> { | |
| 60 | /** | |
| 61 | * Default constructor when using Thymeleaf without all Ogham work. | |
| 62 | * | |
| 63 | * <strong>WARNING: use is only if you know what you are doing !</strong> | |
| 64 | */ | |
| 65 | public ThymeleafV2SmsBuilder() { | |
| 66 | super(ThymeleafV2SmsBuilder.class); | |
| 67 | } | |
| 68 | ||
| 69 | /** | |
| 70 | * Initializes the builder with a parent builder. The parent builder is used | |
| 71 | * when calling {@link #and()} method. The {@link EnvironmentBuilder} is | |
| 72 | * used to evaluate properties when {@link #build()} method is called. | |
| 73 | * | |
| 74 | * @param parent | |
| 75 | * the parent builder | |
| 76 | * @param buildContext | |
| 77 | * for registering instances and property evaluation | |
| 78 | */ | |
| 79 | public ThymeleafV2SmsBuilder(SmsBuilder parent, BuildContext buildContext) { | |
| 80 | super(ThymeleafV2SmsBuilder.class, parent, buildContext); | |
| 81 | } | |
| 82 | ||
| 83 | @Override | |
| 84 | protected TemplateEngineDetector createTemplateDetector() { | |
| 85 |
3
1. createTemplateDetector : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/buider/ThymeleafV2SmsBuilder::createTemplateDetector → NO_COVERAGE 2. createTemplateDetector : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/buider/ThymeleafV2SmsBuilder::createTemplateDetector → KILLED 3. createTemplateDetector : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/buider/ThymeleafV2SmsBuilder::createTemplateDetector → KILLED |
return buildContext.register(new ThymeleafV2TemplateDetector(buildResolver())); |
| 86 | } | |
| 87 | ||
| 88 | @Override | |
| 89 | protected ITemplateResolver buildTemplateResolver(TemplateEngine builtEngine) { | |
| 90 |
3
1. buildTemplateResolver : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/buider/ThymeleafV2SmsBuilder::buildTemplateResolver → NO_COVERAGE 2. buildTemplateResolver : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/buider/ThymeleafV2SmsBuilder::buildTemplateResolver → KILLED 3. buildTemplateResolver : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/buider/ThymeleafV2SmsBuilder::buildTemplateResolver → KILLED |
return buildContext.register(new ThymeLeafV2FirstSupportingTemplateResolver(buildResolver(), buildAdapters())); |
| 91 | } | |
| 92 | ||
| 93 | @Override | |
| 94 | protected ThymeleafV2EngineConfigBuilder<ThymeleafV2SmsBuilder> getThymeleafEngineConfigBuilder() { | |
| 95 |
1
1. getThymeleafEngineConfigBuilder : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/buider/ThymeleafV2SmsBuilder::getThymeleafEngineConfigBuilder → NO_COVERAGE |
return buildContext.register(new ThymeleafV2EngineConfigBuilder<>(myself, buildContext)); |
| 96 | } | |
| 97 | ||
| 98 | @Override | |
| 99 | protected FirstSupportingResolverAdapter buildAdapters() { | |
| 100 | FirstSupportingResolverAdapter adapter = buildContext.register(new FirstSupportingResolverAdapter()); | |
| 101 | for (TemplateResolverAdapter custom : customAdapters) { | |
| 102 |
1
1. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::addAdapter → NO_COVERAGE |
adapter.addAdapter(custom); |
| 103 | } | |
| 104 | ThymeleafV2TemplateOptionsApplier applier = buildContext.register(new ThymeleafV2TemplateOptionsApplier()); | |
| 105 |
3
1. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::addAdapter → NO_COVERAGE 2. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::addAdapter → SURVIVED 3. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::addAdapter → KILLED |
adapter.addAdapter(buildContext.register(new FixClassPathResolverAdapter(applier))); |
| 106 |
2
1. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::addAdapter → SURVIVED 2. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::addAdapter → NO_COVERAGE |
adapter.addAdapter(buildContext.register(new FileResolverAdapter(applier))); |
| 107 |
3
1. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::addAdapter → NO_COVERAGE 2. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::addAdapter → SURVIVED 3. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::addAdapter → KILLED |
adapter.addAdapter(buildContext.register(new StringResolverAdapter(applier))); |
| 108 |
3
1. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::setOptions → NO_COVERAGE 2. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::setOptions → SURVIVED 3. buildAdapters : removed call to fr/sii/ogham/template/thymeleaf/common/adapter/FirstSupportingResolverAdapter::setOptions → KILLED |
adapter.setOptions(buildTemplateResolverOptions()); |
| 109 |
3
1. buildAdapters : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/buider/ThymeleafV2SmsBuilder::buildAdapters → NO_COVERAGE 2. buildAdapters : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/buider/ThymeleafV2SmsBuilder::buildAdapters → SURVIVED 3. buildAdapters : replaced return value with null for fr/sii/ogham/template/thymeleaf/v2/buider/ThymeleafV2SmsBuilder::buildAdapters → KILLED |
return adapter; |
| 110 | } | |
| 111 | } | |
Mutations | ||
| 85 |
1.1 2.2 3.3 |
|
| 90 |
1.1 2.2 3.3 |
|
| 95 |
1.1 |
|
| 102 |
1.1 |
|
| 105 |
1.1 2.2 3.3 |
|
| 106 |
1.1 2.2 |
|
| 107 |
1.1 2.2 3.3 |
|
| 108 |
1.1 2.2 3.3 |
|
| 109 |
1.1 2.2 3.3 |