| 1 | package fr.sii.ogham.core.resource.resolver; | |
| 2 | ||
| 3 | import fr.sii.ogham.core.exception.resource.ResourceResolutionException; | |
| 4 | import fr.sii.ogham.core.resource.Resource; | |
| 5 | import fr.sii.ogham.core.resource.path.ResolvedPath; | |
| 6 | import fr.sii.ogham.core.resource.path.ResolvedResourcePath; | |
| 7 | import fr.sii.ogham.core.resource.path.ResourcePath; | |
| 8 | ||
| 9 | /** | |
| 10 | * Decorates an {@link AbstractPrefixedLookupPathResolver} to manage a default | |
| 11 | * case (no lookup found). | |
| 12 | * | |
| 13 | * @author Cyril Dejonghe | |
| 14 | * | |
| 15 | */ | |
| 16 | public class DefaultResourceResolver implements DelegateResourceResolver { | |
| 17 | /** | |
| 18 | * The delegate resolver that will do the real resource resolution | |
| 19 | */ | |
| 20 | private AbstractPrefixedLookupPathResolver delegate; | |
| 21 | ||
| 22 | /** | |
| 23 | * Initialize the resolver with the mandatory delegate. | |
| 24 | * | |
| 25 | * @param delegate | |
| 26 | * the resolver that will do the real resource resolution | |
| 27 | */ | |
| 28 | public DefaultResourceResolver(AbstractPrefixedLookupPathResolver delegate) { | |
| 29 | super(); | |
| 30 | this.delegate = delegate; | |
| 31 | } | |
| 32 | ||
| 33 | @Override | |
| 34 | public ResolvedPath resolve(ResourcePath path) { | |
| 35 | ResolvedPath result = delegate.resolve(path); | |
| 36 |
1
1. resolve : negated conditional → NO_COVERAGE |
if (result == null) { |
| 37 | result = new ResolvedResourcePath(path, null, path.getOriginalPath()); | |
| 38 | } | |
| 39 |
1
1. resolve : replaced return value with null for fr/sii/ogham/core/resource/resolver/DefaultResourceResolver::resolve → NO_COVERAGE |
return result; |
| 40 | } | |
| 41 | ||
| 42 | @Override | |
| 43 | public boolean supports(ResourcePath path) { | |
| 44 |
1
1. supports : replaced boolean return with false for fr/sii/ogham/core/resource/resolver/DefaultResourceResolver::supports → NO_COVERAGE |
return true; |
| 45 | } | |
| 46 | ||
| 47 | @Override | |
| 48 | public Resource getResource(ResourcePath path) throws ResourceResolutionException { | |
| 49 |
1
1. getResource : replaced return value with null for fr/sii/ogham/core/resource/resolver/DefaultResourceResolver::getResource → NO_COVERAGE |
return delegate.getResource(resolve(path)); |
| 50 | } | |
| 51 | ||
| 52 | @Override | |
| 53 | public ResourceResolver getActualResourceResolver() { | |
| 54 |
2
1. getActualResourceResolver : negated conditional → NO_COVERAGE 2. getActualResourceResolver : replaced return value with null for fr/sii/ogham/core/resource/resolver/DefaultResourceResolver::getActualResourceResolver → NO_COVERAGE |
return delegate instanceof DelegateResourceResolver ? ((DelegateResourceResolver) delegate).getActualResourceResolver() : delegate; |
| 55 | } | |
| 56 | } | |
Mutations | ||
| 36 |
1.1 |
|
| 39 |
1.1 |
|
| 44 |
1.1 |
|
| 49 |
1.1 |
|
| 54 |
1.1 2.2 |