| 1 | package fr.sii.ogham.core.translator.resource; | |
| 2 | ||
| 3 | import org.slf4j.Logger; | |
| 4 | import org.slf4j.LoggerFactory; | |
| 5 | ||
| 6 | import fr.sii.ogham.core.resource.OverrideNameWrapper; | |
| 7 | import fr.sii.ogham.core.resource.Resource; | |
| 8 | import fr.sii.ogham.email.exception.attachment.translator.ResourceTranslatorException; | |
| 9 | ||
| 10 | /** | |
| 11 | * <p> | |
| 12 | * Translator that handles {@link OverrideNameWrapper}. It delegates to another | |
| 13 | * {@link AttachmentResourceTranslator} to get handle the wrapped | |
| 14 | * {@link Resource}. The handled {@link Resource} is then re-wrapped into a | |
| 15 | * {@link OverrideNameWrapper}. | |
| 16 | * | |
| 17 | * @author Aurélien Baudet | |
| 18 | * | |
| 19 | */ | |
| 20 | public class OverrideNameWrapperResourceTranslator implements AttachmentResourceTranslator { | |
| 21 | private static final Logger LOG = LoggerFactory.getLogger(OverrideNameWrapperResourceTranslator.class); | |
| 22 | ||
| 23 | private final AttachmentResourceTranslator delegate; | |
| 24 | ||
| 25 | public OverrideNameWrapperResourceTranslator(AttachmentResourceTranslator delegate) { | |
| 26 | super(); | |
| 27 | this.delegate = delegate; | |
| 28 | } | |
| 29 | ||
| 30 | @Override | |
| 31 | public Resource translate(Resource resource) throws ResourceTranslatorException { | |
| 32 |
3
1. translate : negated conditional → NO_COVERAGE 2. translate : negated conditional → KILLED 3. translate : negated conditional → KILLED |
if (resource instanceof OverrideNameWrapper) { |
| 33 | OverrideNameWrapper namedResource = (OverrideNameWrapper) resource; | |
| 34 | Resource translated = delegate.translate(namedResource.getDelegate()); | |
| 35 |
2
1. translate : replaced return value with null for fr/sii/ogham/core/translator/resource/OverrideNameWrapperResourceTranslator::translate → NO_COVERAGE 2. translate : replaced return value with null for fr/sii/ogham/core/translator/resource/OverrideNameWrapperResourceTranslator::translate → KILLED |
return new OverrideNameWrapper(translated, namedResource.getName()); |
| 36 | } else { | |
| 37 | LOG.trace("Not a OverrideNameWrapper => skip it"); | |
| 38 |
3
1. translate : replaced return value with null for fr/sii/ogham/core/translator/resource/OverrideNameWrapperResourceTranslator::translate → NO_COVERAGE 2. translate : replaced return value with null for fr/sii/ogham/core/translator/resource/OverrideNameWrapperResourceTranslator::translate → KILLED 3. translate : replaced return value with null for fr/sii/ogham/core/translator/resource/OverrideNameWrapperResourceTranslator::translate → KILLED |
return resource; |
| 39 | } | |
| 40 | } | |
| 41 | ||
| 42 | @Override | |
| 43 | public String toString() { | |
| 44 |
3
1. toString : replaced return value with "" for fr/sii/ogham/core/translator/resource/OverrideNameWrapperResourceTranslator::toString → SURVIVED 2. toString : replaced return value with "" for fr/sii/ogham/core/translator/resource/OverrideNameWrapperResourceTranslator::toString → NO_COVERAGE 3. toString : replaced return value with "" for fr/sii/ogham/core/translator/resource/OverrideNameWrapperResourceTranslator::toString → TIMED_OUT |
return "OverrideNameWrapperResourceTranslator"; |
| 45 | } | |
| 46 | ||
| 47 | } | |
Mutations | ||
| 32 |
1.1 2.2 3.3 |
|
| 35 |
1.1 2.2 |
|
| 38 |
1.1 2.2 3.3 |
|
| 44 |
1.1 2.2 3.3 |