| 1 | package fi.eis.libraries.di; | |
| 2 | ||
| 3 | import java.io.File; | |
| 4 | import java.util.List; | |
| 5 | import java.util.Map; | |
| 6 | ||
| 7 | import fi.eis.libraries.di.context.configclass.ConfigurationClassContext; | |
| 8 | import fi.eis.libraries.di.context.Context; | |
| 9 | import fi.eis.libraries.di.context.deployment.DeploymentUnitContext; | |
| 10 | import fi.eis.libraries.di.context.Module; | |
| 11 | import fi.eis.libraries.di.logger.LogLevel; | |
| 12 | ||
| 13 | /** | |
| 14 | * | |
| 15 | * Main entrypoint class for the dependency injection. It supports three forms of dependency | |
| 16 | * injection: you can | |
| 17 | * 1) ask it to create a context from the deployment unit (e.g. jar) in question (deploymentUnitContext()) | |
| 18 | * 2) ask it to create a context based on spring-style configuration class (configurationClassContext()) | |
| 19 | * 3) list the classes and their instances explicitly as modules and ask it to create a context based on that (module() + context()) | |
| 20 | * 4) list the classes explicitly and ask it to create a context based on that (context()) | |
| 21 | * @author eis | |
| 22 | */ | |
| 23 | public class DependencyInjection { | |
| 24 | public static Module module(Class... classes) { | |
| 25 |
2
1. module : removed call to fi/eis/libraries/di/context/Module::<init> → KILLED 2. module : replaced return value with null for fi/eis/libraries/di/DependencyInjection::module → KILLED |
return new Module(classes); |
| 26 | } | |
| 27 | public static Module module(List<Class> classes) { | |
| 28 |
2
1. module : replaced return value with null for fi/eis/libraries/di/DependencyInjection::module → NO_COVERAGE 2. module : removed call to fi/eis/libraries/di/context/Module::<init> → NO_COVERAGE |
return new Module(classes); |
| 29 | } | |
| 30 | public static Module module(Map<Class,Object> classesWithInstances) { | |
| 31 |
2
1. module : replaced return value with null for fi/eis/libraries/di/DependencyInjection::module → KILLED 2. module : removed call to fi/eis/libraries/di/context/Module::<init> → KILLED |
return new Module(classesWithInstances); |
| 32 | } | |
| 33 | public static Context context(Module... modules) { | |
| 34 | // add all other modules to combined one | |
| 35 |
2
1. context : removed call to fi/eis/libraries/di/context/Module::<init> → KILLED 2. context : Substituted 0 with 1 → KILLED |
Module combinedModule = new Module(); |
| 36 | for (Module module: modules) { | |
| 37 |
1
1. context : removed call to fi/eis/libraries/di/context/Module::add → KILLED |
combinedModule.add(module); |
| 38 | } | |
| 39 | // create a new module based on combined one | |
| 40 |
4
1. context : replaced return value with null for fi/eis/libraries/di/DependencyInjection::context → KILLED 2. context : Substituted 0 with 1 → KILLED 3. context : removed call to fi/eis/libraries/di/context/Context::<init> → KILLED 4. context : Substituted 1 with 0 → KILLED |
return new Context(combinedModule); |
| 41 | } | |
| 42 | ||
| 43 | public static Context context(Class... classes) { | |
| 44 | // create a new module based on given classes | |
| 45 |
5
1. context : Substituted 1 with 0 → KILLED 2. context : Substituted 0 with 1 → KILLED 3. context : removed call to fi/eis/libraries/di/context/Context::<init> → KILLED 4. context : removed call to fi/eis/libraries/di/context/Module::<init> → KILLED 5. context : replaced return value with null for fi/eis/libraries/di/DependencyInjection::context → KILLED |
return new Context(new Module(classes)); |
| 46 | } | |
| 47 | ||
| 48 | public static Context deploymentUnitContext(Class sourceClass) { | |
| 49 |
2
1. deploymentUnitContext : removed call to fi/eis/libraries/di/context/deployment/DeploymentUnitContext::<init> → KILLED 2. deploymentUnitContext : replaced return value with null for fi/eis/libraries/di/DependencyInjection::deploymentUnitContext → KILLED |
return new DeploymentUnitContext(sourceClass); |
| 50 | } | |
| 51 | public static Context deploymentUnitContext(File jarFile) { | |
| 52 |
2
1. deploymentUnitContext : removed call to fi/eis/libraries/di/context/deployment/DeploymentUnitContext::<init> → KILLED 2. deploymentUnitContext : replaced return value with null for fi/eis/libraries/di/DependencyInjection::deploymentUnitContext → KILLED |
return new DeploymentUnitContext(jarFile); |
| 53 | } | |
| 54 | public static Context deploymentUnitContext(Class sourceClass, LogLevel logLevel) { | |
| 55 |
2
1. deploymentUnitContext : removed call to fi/eis/libraries/di/context/deployment/DeploymentUnitContext::<init> → KILLED 2. deploymentUnitContext : replaced return value with null for fi/eis/libraries/di/DependencyInjection::deploymentUnitContext → KILLED |
return new DeploymentUnitContext(sourceClass, logLevel); |
| 56 | } | |
| 57 | public static Context deploymentUnitContext(File jarFile, LogLevel logLevel) { | |
| 58 |
2
1. deploymentUnitContext : replaced return value with null for fi/eis/libraries/di/DependencyInjection::deploymentUnitContext → NO_COVERAGE 2. deploymentUnitContext : removed call to fi/eis/libraries/di/context/deployment/DeploymentUnitContext::<init> → NO_COVERAGE |
return new DeploymentUnitContext(jarFile, logLevel); |
| 59 | } | |
| 60 | ||
| 61 | public static Context configurationClassContext(Class... exampleJavaConfigClass) { | |
| 62 |
2
1. configurationClassContext : replaced return value with null for fi/eis/libraries/di/DependencyInjection::configurationClassContext → NO_COVERAGE 2. configurationClassContext : removed call to fi/eis/libraries/di/context/configclass/ConfigurationClassContext::<init> → NO_COVERAGE |
return new ConfigurationClassContext(exampleJavaConfigClass); |
| 63 | } | |
| 64 | public static Context configurationClassContext(LogLevel logLevel, Class... exampleJavaConfigClass) { | |
| 65 |
2
1. configurationClassContext : removed call to fi/eis/libraries/di/context/configclass/ConfigurationClassContext::<init> → KILLED 2. configurationClassContext : replaced return value with null for fi/eis/libraries/di/DependencyInjection::configurationClassContext → KILLED |
return new ConfigurationClassContext(logLevel, exampleJavaConfigClass); |
| 66 | } | |
| 67 | } | |
Mutations | ||
| 25 |
1.1 2.2 |
|
| 28 |
1.1 2.2 |
|
| 31 |
1.1 2.2 |
|
| 35 |
1.1 2.2 |
|
| 37 |
1.1 |
|
| 40 |
1.1 2.2 3.3 4.4 |
|
| 45 |
1.1 2.2 3.3 4.4 5.5 |
|
| 49 |
1.1 2.2 |
|
| 52 |
1.1 2.2 |
|
| 55 |
1.1 2.2 |
|
| 58 |
1.1 2.2 |
|
| 62 |
1.1 2.2 |
|
| 65 |
1.1 2.2 |