blob: 1dae6e7baa90c83b0572872c441fb25d6fe39a92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package bjc.utils.components;
import bjc.utils.funcdata.IMap;
/**
* A repository of components stored in memory.
*
* @author bjculkin
*
* @param <ComponentType> The type of component stored in the repository.
*/
public class MemoryComponentRepository<ComponentType extends IDescribedComponent>
implements IComponentRepository<ComponentType> {
private final IMap<String, ComponentType> repo;
private final String source;
/**
* Create a new memory component repository.
*
* @param repo
* The set of components to use.
*/
public MemoryComponentRepository(IMap<String, ComponentType> repo) {
this(repo, "memory");
}
/**
* Create a new memory component repository.
*
* @param repo
* The set of components to use.
* @param source
* Where the components came from.
*/
public MemoryComponentRepository(IMap<String, ComponentType> repo, String source) {
this.repo = repo;
this.source = source;
}
@Override
public IMap<String, ComponentType> getAll() {
return repo;
}
public ComponentType getByName(String name) {
return repo.get(name);
}
public String getSource() {
return source;
}
}
|