| 1 | package fr.sii.ogham.core.builder.resolution; | |
| 2 | ||
| 3 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilder; | |
| 4 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderDelegate; | |
| 5 | import fr.sii.ogham.core.builder.context.BuildContext; | |
| 6 | import fr.sii.ogham.core.builder.env.EnvironmentBuilder; | |
| 7 | import fr.sii.ogham.core.resource.resolver.ClassPathResolver; | |
| 8 | import fr.sii.ogham.core.resource.resolver.ResourceResolver; | |
| 9 | ||
| 10 | /** | |
| 11 | * Configure resource resolver that loads files from classpath. | |
| 12 | * | |
| 13 | * <p> | |
| 14 | * You can define the lookup (the prefix that indicates that classpath | |
| 15 | * resolution must be used). For example: | |
| 16 | * | |
| 17 | * <pre> | |
| 18 | * .classpath().lookup("classpath:"); | |
| 19 | * | |
| 20 | * // path prefixed by classpath: matches | |
| 21 | * // then classpath resolver is used | |
| 22 | * resourceResolver.getResource("classpath:foo/bar.html"); | |
| 23 | * // path is not prefixed (or using another prefix) doesn't match | |
| 24 | * // then classpath resolver is not used | |
| 25 | * resourceResolver.getResource("foo/bar.html"); | |
| 26 | * </pre> | |
| 27 | * | |
| 28 | * <p> | |
| 29 | * You can define a path prefix and suffix for finding resources: | |
| 30 | * | |
| 31 | * <pre> | |
| 32 | * .classpath().lookup("classpath:").pathPrefix("foo/").pathSuffix(".html"); | |
| 33 | * | |
| 34 | * resourceResolver.getResource("bar"); | |
| 35 | * </pre> | |
| 36 | * | |
| 37 | * This will use the classpath resolver and the real path is | |
| 38 | * {@code foo/bar.html}. | |
| 39 | * | |
| 40 | * | |
| 41 | * @author Aurélien Baudet | |
| 42 | * | |
| 43 | * @param <P> | |
| 44 | * the type of the parent builder (when calling {@link #and()} | |
| 45 | * method) | |
| 46 | */ | |
| 47 | public class ClassPathResolutionBuilder<P> extends AbstractSingleResolutionBuilder<ClassPathResolutionBuilder<P>, P> implements PrefixSuffixBuilder<ClassPathResolutionBuilder<P>> { | |
| 48 | ||
| 49 | /** | |
| 50 | * Initializes with the parent builder and the {@link EnvironmentBuilder}. | |
| 51 | * The parent builder is used when calling the {@link #and()} method. The | |
| 52 | * {@link EnvironmentBuilder} is used when calling {@link #build()} method | |
| 53 | * in order to evaluate property values. | |
| 54 | * | |
| 55 | * @param parent | |
| 56 | * the parent builder | |
| 57 | * @param buildContext | |
| 58 | * for property resolution | |
| 59 | */ | |
| 60 | public ClassPathResolutionBuilder(P parent, BuildContext buildContext) { | |
| 61 | super(ClassPathResolutionBuilder.class, parent, buildContext); | |
| 62 | } | |
| 63 | ||
| 64 | @Override | |
| 65 | protected ResourceResolver createResolver() { | |
| 66 |
8
1. createResolver : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::createResolver → SURVIVED 2. createResolver : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::createResolver → NO_COVERAGE 3. createResolver : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::createResolver → KILLED 4. createResolver : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::createResolver → KILLED 5. createResolver : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::createResolver → KILLED 6. createResolver : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::createResolver → KILLED 7. createResolver : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::createResolver → KILLED 8. createResolver : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::createResolver → KILLED |
return new ClassPathResolver(lookups); |
| 67 | } | |
| 68 | ||
| 69 | @Override | |
| 70 | public ClassPathResolutionBuilder<P> pathPrefix(String prefix) { | |
| 71 |
5
1. pathPrefix : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE 2. pathPrefix : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED 3. pathPrefix : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED 4. pathPrefix : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED 5. pathPrefix : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → KILLED |
pathPrefixValueBuilder.setValue(prefix); |
| 72 |
5
1. pathPrefix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathPrefix → NO_COVERAGE 2. pathPrefix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathPrefix → KILLED 3. pathPrefix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathPrefix → KILLED 4. pathPrefix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathPrefix → KILLED 5. pathPrefix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathPrefix → KILLED |
return myself; |
| 73 | } | |
| 74 | ||
| 75 | @Override | |
| 76 | public ConfigurationValueBuilder<ClassPathResolutionBuilder<P>, String> pathPrefix() { | |
| 77 |
4
1. pathPrefix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathPrefix → NO_COVERAGE 2. pathPrefix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathPrefix → KILLED 3. pathPrefix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathPrefix → KILLED 4. pathPrefix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathPrefix → KILLED |
return new ConfigurationValueBuilderDelegate<>(myself, pathPrefixValueBuilder); |
| 78 | } | |
| 79 | ||
| 80 | @Override | |
| 81 | public ClassPathResolutionBuilder<P> pathSuffix(String suffix) { | |
| 82 |
1
1. pathSuffix : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE |
pathSuffixValueBuilder.setValue(suffix); |
| 83 |
1
1. pathSuffix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathSuffix → NO_COVERAGE |
return myself; |
| 84 | } | |
| 85 | ||
| 86 | @Override | |
| 87 | public ConfigurationValueBuilder<ClassPathResolutionBuilder<P>, String> pathSuffix() { | |
| 88 |
4
1. pathSuffix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathSuffix → NO_COVERAGE 2. pathSuffix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathSuffix → KILLED 3. pathSuffix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathSuffix → KILLED 4. pathSuffix : replaced return value with null for fr/sii/ogham/core/builder/resolution/ClassPathResolutionBuilder::pathSuffix → KILLED |
return new ConfigurationValueBuilderDelegate<>(myself, pathSuffixValueBuilder); |
| 89 | } | |
| 90 | } | |
Mutations | ||
| 66 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
| 71 |
1.1 2.2 3.3 4.4 5.5 |
|
| 72 |
1.1 2.2 3.3 4.4 5.5 |
|
| 77 |
1.1 2.2 3.3 4.4 |
|
| 82 |
1.1 |
|
| 83 |
1.1 |
|
| 88 |
1.1 2.2 3.3 4.4 |