DefaultBuildContext.java

1
package fr.sii.ogham.core.builder.context;
2
3
import java.util.List;
4
import java.util.Properties;
5
import java.util.function.Function;
6
7
import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilder;
8
import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper;
9
import fr.sii.ogham.core.convert.Converter;
10
import fr.sii.ogham.core.convert.DefaultConverter;
11
import fr.sii.ogham.core.env.JavaPropertiesResolver;
12
import fr.sii.ogham.core.env.PropertyResolver;
13
import fr.sii.ogham.core.util.BuilderUtils;
14
15
/**
16
 * Simple build context that uses a default {@link PropertyResolver} and a
17
 * default {@link Converter}.
18
 * 
19
 * <p>
20
 * <strong>WARNING: don't use it, this is for for advanced usage only
21
 * !!!</strong>
22
 * 
23
 * 
24
 * @author Aurélien Baudet
25
 *
26
 */
27
public class DefaultBuildContext implements BuildContext {
28
	private final PropertyResolver propertyResolver;
29
	private final Converter converter;
30
31
	public DefaultBuildContext() {
32
		this(new Properties());
33
	}
34
35
	public DefaultBuildContext(Properties props) {
36
		super();
37
		this.converter = new DefaultConverter();
38
		this.propertyResolver = new JavaPropertiesResolver(props, converter);
39
	}
40
41
	@Override
42
	public <T> T register(T instance) {
43 1 1. register : replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::register → RUN_ERROR
		return instance;
44
	}
45
46
	@Override
47
	public <T> T evaluate(List<String> properties, Class<T> resultClass) {
48 1 1. evaluate : replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::evaluate → RUN_ERROR
		return BuilderUtils.evaluate(properties, getPropertyResolver(), resultClass);
49
	}
50
51
	@Override
52
	public PropertyResolver getPropertyResolver() {
53 1 1. getPropertyResolver : replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::getPropertyResolver → RUN_ERROR
		return propertyResolver;
54
	}
55
56
	@Override
57
	public Converter getConverter() {
58 1 1. getConverter : replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::getConverter → NO_COVERAGE
		return converter;
59
	}
60
61
	@Override
62
	@SuppressWarnings("unchecked")
63
	public <P, V, T extends ConfigurationValueBuilder<P, V>> T newConfigurationValueBuilder(P parent, Class<V> valueClass) {
64 2 1. lambda$newConfigurationValueBuilder$0 : replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::lambda$newConfigurationValueBuilder$0 → RUN_ERROR
2. newConfigurationValueBuilder : replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::newConfigurationValueBuilder → RUN_ERROR
		return newConfigurationValueBuilder(ctx -> (T) new ConfigurationValueBuilderHelper<>(parent, valueClass, ctx));
65
	}
66
67
	@Override
68
	public <P, V, T extends ConfigurationValueBuilder<P, V>> T newConfigurationValueBuilder(Function<BuildContext, T> factory) {
69 1 1. newConfigurationValueBuilder : replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::newConfigurationValueBuilder → RUN_ERROR
		return factory.apply(this);
70
	}
71
72
}

Mutations

43

1.1
Location : register
Killed by :
replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::register → RUN_ERROR

48

1.1
Location : evaluate
Killed by :
replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::evaluate → RUN_ERROR

53

1.1
Location : getPropertyResolver
Killed by :
replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::getPropertyResolver → RUN_ERROR

58

1.1
Location : getConverter
Killed by :
replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::getConverter → NO_COVERAGE

64

1.1
Location : lambda$newConfigurationValueBuilder$0
Killed by :
replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::lambda$newConfigurationValueBuilder$0 → RUN_ERROR

2.2
Location : newConfigurationValueBuilder
Killed by :
replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::newConfigurationValueBuilder → RUN_ERROR

69

1.1
Location : newConfigurationValueBuilder
Killed by :
replaced return value with null for fr/sii/ogham/core/builder/context/DefaultBuildContext::newConfigurationValueBuilder → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1