EnvBuilderBasedContext.java

1
package fr.sii.ogham.core.builder.context;
2
3
import java.util.List;
4
import java.util.function.Function;
5
6
import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilder;
7
import fr.sii.ogham.core.builder.configuration.ConfigurationValueBuilderHelper;
8
import fr.sii.ogham.core.builder.env.EnvironmentBuilder;
9
import fr.sii.ogham.core.builder.registry.Registry;
10
import fr.sii.ogham.core.convert.Converter;
11
import fr.sii.ogham.core.env.PropertyResolver;
12
import fr.sii.ogham.core.util.BuilderUtils;
13
14
/**
15
 * Context that uses a shared {@link EnvironmentBuilder} to evaluate the
16
 * properties. The converter is the same as used by the
17
 * {@link EnvironmentBuilder}.
18
 * 
19
 * <p>
20
 * This implementation delegates registration of instances to the provided
21
 * registry. Any instance may be registered.
22
 * 
23
 * @author Aurélien Baudet
24
 *
25
 */
26
public class EnvBuilderBasedContext implements BuildContext {
27
	private final EnvironmentBuilder<?> environmentBuilder;
28
	private final Registry<Object> registry;
29
30
	public EnvBuilderBasedContext(EnvironmentBuilder<?> environmentBuilder, Registry<Object> registry) {
31
		super();
32
		this.environmentBuilder = environmentBuilder;
33
		this.registry = registry;
34
	}
35
36
	@Override
37
	public <T> T register(T instance) {
38 1 1. register : removed call to fr/sii/ogham/core/builder/registry/Registry::register → RUN_ERROR
		registry.register(instance);
39 1 1. register : replaced return value with null for fr/sii/ogham/core/builder/context/EnvBuilderBasedContext::register → RUN_ERROR
		return instance;
40
	}
41
42
	@Override
43
	public <T> T evaluate(List<String> properties, Class<T> resultClass) {
44 1 1. evaluate : replaced return value with null for fr/sii/ogham/core/builder/context/EnvBuilderBasedContext::evaluate → RUN_ERROR
		return BuilderUtils.evaluate(properties, getPropertyResolver(), resultClass);
45
	}
46
47
	@Override
48
	public PropertyResolver getPropertyResolver() {
49 1 1. getPropertyResolver : replaced return value with null for fr/sii/ogham/core/builder/context/EnvBuilderBasedContext::getPropertyResolver → RUN_ERROR
		return environmentBuilder.build();
50
	}
51
52
	@Override
53
	public Converter getConverter() {
54 1 1. getConverter : replaced return value with null for fr/sii/ogham/core/builder/context/EnvBuilderBasedContext::getConverter → NO_COVERAGE
		return environmentBuilder.converter().build();
55
	}
56
57
	@Override
58
	@SuppressWarnings("unchecked")
59
	public <P, V, T extends ConfigurationValueBuilder<P, V>> T newConfigurationValueBuilder(P parent, Class<V> valueClass) {
60 2 1. newConfigurationValueBuilder : replaced return value with null for fr/sii/ogham/core/builder/context/EnvBuilderBasedContext::newConfigurationValueBuilder → RUN_ERROR
2. lambda$newConfigurationValueBuilder$0 : replaced return value with null for fr/sii/ogham/core/builder/context/EnvBuilderBasedContext::lambda$newConfigurationValueBuilder$0 → RUN_ERROR
		return newConfigurationValueBuilder(ctx -> (T) new ConfigurationValueBuilderHelper<>(parent, valueClass, ctx));
61
	}
62
63
	@Override
64
	public <P, V, T extends ConfigurationValueBuilder<P, V>> T newConfigurationValueBuilder(Function<BuildContext, T> factory) {
65 1 1. newConfigurationValueBuilder : replaced return value with null for fr/sii/ogham/core/builder/context/EnvBuilderBasedContext::newConfigurationValueBuilder → RUN_ERROR
		return factory.apply(this);
66
	}
67
}

Mutations

38

1.1
Location : register
Killed by :
removed call to fr/sii/ogham/core/builder/registry/Registry::register → RUN_ERROR

39

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

44

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

49

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

54

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

60

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

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

65

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

Active mutators

Tests examined


Report generated by PIT 1.13.1