| 10 | import org.apache.logging.log4j.Logger; |
| 11 | |
| 12 | public class RegistrySimple<K, V> implements IRegistry<K, V> |
| 13 | { |
| 14 | private static final Logger logger = LogManager.getLogger(); |
| 15 | protected final Map<K, V> registryObjects = this.createUnderlyingMap(); |
| 16 | |
| 17 | protected Map<K, V> createUnderlyingMap() |
| 18 | { |
| 19 | return Maps.<K, V>newHashMap(); |
| 20 | } |
| 21 | |
| 22 | public V getObject(K name) |
| 23 | { |
| 24 | return this.registryObjects.get(name); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Register an object on this registry. |
| 29 | */ |
| 30 | public void putObject(K p_82595_1_, V p_82595_2_) |
| 31 | { |
| 32 | Validate.notNull(p_82595_1_); |
| 33 | Validate.notNull(p_82595_2_); |
| 34 | |
| 35 | if (this.registryObjects.containsKey(p_82595_1_)) |
| 36 | { |
| 37 | logger.debug("Adding duplicate key \'" + p_82595_1_ + "\' to registry"); |
| 38 | } |
| 39 | |
| 40 | this.registryObjects.put(p_82595_1_, p_82595_2_); |
| 41 | } |
| 42 | |
| 43 | public Set<K> getKeys() |
| 44 | { |
| 45 | return Collections.<K>unmodifiableSet(this.registryObjects.keySet()); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Does this registry contain an entry for the given key? |
| 50 | */ |
| 51 | public boolean containsKey(K p_148741_1_) |
| 52 | { |
| 53 | return this.registryObjects.containsKey(p_148741_1_); |
| 54 | } |
| 55 | |
| 56 | public Iterator<V> iterator() |
| 57 | { |
| 58 | return this.registryObjects.values().iterator(); |
| 59 | } |
| 60 | } |
nothing calls this directly
no test coverage detected