mirror of https://github.com/tasks/tasks
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
Java
54 lines
1.4 KiB
Java
/**
|
|
* Copyright (c) 2012 Todoroo Inc
|
|
*
|
|
* See the file "LICENSE" for the full license governing this code.
|
|
*/
|
|
package com.todoroo.astrid.test;
|
|
|
|
import com.todoroo.andlib.service.AbstractDependencyInjector;
|
|
import com.todoroo.andlib.service.DependencyInjectionService;
|
|
|
|
|
|
public class TestDependencyInjector extends AbstractDependencyInjector {
|
|
|
|
private String name;
|
|
|
|
public TestDependencyInjector(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public void addInjectable(String field, Object injection) {
|
|
injectables.put(field, injection);
|
|
}
|
|
|
|
@Override
|
|
protected void addInjectables() {
|
|
// do nothing, we populate injectables via the addInjectable method
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "TestDI:" + name;
|
|
}
|
|
|
|
// --- static stuff
|
|
|
|
/**
|
|
* Install TestDependencyInjector above other injectors
|
|
*/
|
|
public synchronized static TestDependencyInjector initialize(String name) {
|
|
TestDependencyInjector instance = new TestDependencyInjector(name);
|
|
DependencyInjectionService.getInstance().addInjector(instance);
|
|
return instance;
|
|
}
|
|
|
|
/**
|
|
* Remove an installed TestDependencyInjector
|
|
* @param string
|
|
*/
|
|
public static void deinitialize(TestDependencyInjector instance) {
|
|
DependencyInjectionService.getInstance().removeInjector(instance);
|
|
}
|
|
|
|
}
|