blob: 2e11616b95d1ff971b99b1277bbd5504c9c19976 (
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
55
56
57
|
package bjc.utils.components;
import bjc.funcdata.MapEx;
/**
* 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 MapEx<String, ComponentType> repo;
private final String source;
/**
* Create a new memory component repository.
*
* @param repo
* The set of components to use.
*/
public MemoryComponentRepository(MapEx<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(MapEx<String, ComponentType> repo, String source) {
this.repo = repo;
this.source = source;
}
@Override
public MapEx<String, ComponentType> getAll() {
return repo;
}
@Override
public ComponentType getByName(String name) {
return repo.get(name).get();
}
@Override
public String getSource() {
return source;
}
}
|