| 1 | package fr.sii.ogham.core.builder.charset; | |
| 2 | ||
| 3 | import java.nio.charset.Charset; | |
| 4 | ||
| 5 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilder; | |
| 6 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderDelegate; | |
| 7 | import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper; | |
| 8 | import fr.sii.ogham.core.builder.context.BuildContext; | |
| 9 | import fr.sii.ogham.core.builder.env.EnvironmentBuilder; | |
| 10 | import fr.sii.ogham.core.charset.CharsetDetector; | |
| 11 | import fr.sii.ogham.core.charset.FixedCharsetDetector; | |
| 12 | import fr.sii.ogham.core.fluent.AbstractParent; | |
| 13 | ||
| 14 | public class SimpleCharsetDetectorBuilder<P> extends AbstractParent<P> implements CharsetDetectorBuilder<P> { | |
| 15 | private final ConfigurationValueBuilderHelper<SimpleCharsetDetectorBuilder<P>, String> charsetValueBuilder; | |
| 16 | ||
| 17 | /** | |
| 18 | * Initializes the builder with a parent builder. The parent builder is used | |
| 19 | * when calling {@link #and()} method. The {@link EnvironmentBuilder} is | |
| 20 | * used to evaluate properties when {@link #build()} method is called. | |
| 21 | * | |
| 22 | * @param parent | |
| 23 | * the parent builder | |
| 24 | * @param buildContext | |
| 25 | * for registering instances and property evaluation | |
| 26 | */ | |
| 27 | public SimpleCharsetDetectorBuilder(P parent, BuildContext buildContext) { | |
| 28 | super(parent); | |
| 29 | charsetValueBuilder = buildContext.newConfigurationValueBuilder(this, String.class); | |
| 30 | } | |
| 31 | ||
| 32 | @Override | |
| 33 | public CharsetDetectorBuilder<P> defaultCharset(String charsetName) { | |
| 34 |
1
1. defaultCharset : removed call to fr/sii/ogham/core/builder/configuration/ConfigurationValueBuilderHelper::setValue → NO_COVERAGE |
charsetValueBuilder.setValue(charsetName); |
| 35 |
1
1. defaultCharset : replaced return value with null for fr/sii/ogham/core/builder/charset/SimpleCharsetDetectorBuilder::defaultCharset → NO_COVERAGE |
return this; |
| 36 | } | |
| 37 | ||
| 38 | @Override | |
| 39 | public ConfigurationValueBuilder<CharsetDetectorBuilder<P>, String> defaultCharset() { | |
| 40 |
1
1. defaultCharset : replaced return value with null for fr/sii/ogham/core/builder/charset/SimpleCharsetDetectorBuilder::defaultCharset → NO_COVERAGE |
return new ConfigurationValueBuilderDelegate<>(this, charsetValueBuilder); |
| 41 | } | |
| 42 | ||
| 43 | @Override | |
| 44 | public CharsetDetector build() { | |
| 45 |
1
1. build : replaced return value with null for fr/sii/ogham/core/builder/charset/SimpleCharsetDetectorBuilder::build → NO_COVERAGE |
return new FixedCharsetDetector(getDefaultCharset(charsetValueBuilder)); |
| 46 | } | |
| 47 | ||
| 48 | private static Charset getDefaultCharset(ConfigurationValueBuilderHelper<?, String> valueBuilder) { | |
| 49 | String charset = valueBuilder.getValue(); | |
| 50 |
1
1. getDefaultCharset : negated conditional → NO_COVERAGE |
if (charset != null) { |
| 51 |
1
1. getDefaultCharset : replaced return value with null for fr/sii/ogham/core/builder/charset/SimpleCharsetDetectorBuilder::getDefaultCharset → NO_COVERAGE |
return Charset.forName(charset); |
| 52 | } | |
| 53 |
1
1. getDefaultCharset : replaced return value with null for fr/sii/ogham/core/builder/charset/SimpleCharsetDetectorBuilder::getDefaultCharset → NO_COVERAGE |
return Charset.defaultCharset(); |
| 54 | } | |
| 55 | ||
| 56 | } | |
Mutations | ||
| 34 |
1.1 |
|
| 35 |
1.1 |
|
| 40 |
1.1 |
|
| 45 |
1.1 |
|
| 50 |
1.1 |
|
| 51 |
1.1 |
|
| 53 |
1.1 |