|
21 | 21 | import com.google.common.collect.Maps; |
22 | 22 | import com.google.common.collect.Sets; |
23 | 23 | import com.google.common.collect.Table; |
| 24 | +import org.slf4j.Logger; |
| 25 | +import org.slf4j.LoggerFactory; |
24 | 26 | import org.terasology.naming.Name; |
25 | 27 | import org.terasology.naming.Version; |
26 | 28 |
|
|
37 | 39 | */ |
38 | 40 | public class TableModuleRegistry implements ModuleRegistry { |
39 | 41 |
|
| 42 | + private static final Logger logger = LoggerFactory.getLogger(TableModuleRegistry.class); |
| 43 | + |
40 | 44 | private final Table<Name, Version, Module> modules = HashBasedTable.create(); |
41 | 45 | private final Map<Name, Module> latestModules = Maps.newHashMap(); |
42 | 46 |
|
43 | 47 | @Override |
44 | 48 | public boolean add(Module module) { |
45 | 49 | Preconditions.checkNotNull(module); |
46 | | - if (!modules.contains(module.getId(), module.getVersion()) || modules.get(module.getId(), module.getVersion()).getVersion().isSnapshot()) { |
| 50 | + if (!modules.contains(module.getId(), module.getVersion())) { |
47 | 51 | modules.put(module.getId(), module.getVersion(), module); |
48 | 52 | Module previousLatest = latestModules.get(module.getId()); |
49 | 53 | if (previousLatest == null || previousLatest.getVersion().compareTo(module.getVersion()) <= 0) { |
50 | 54 | latestModules.put(module.getId(), module); |
51 | 55 | } |
52 | 56 | return true; |
| 57 | + } else { |
| 58 | + logger.error("Module {}-{} already registered from {}, cannot register same module from {}", |
| 59 | + module.getId(), |
| 60 | + module.getVersion(), |
| 61 | + modules.get(module.getId(), module.getVersion()).getLocations(), |
| 62 | + module.getLocations()); |
53 | 63 | } |
54 | 64 | return false; |
55 | 65 | } |
|
0 commit comments