RegistrySimple .java

net.minecraft.util.RegistrySimple (class): members: registryObjects, putObject, createUnderlyingMap, containsKey, getObject, getKeys, iterator, logger.

net.minecraft.utilclass61 linescommon1.4 KB

Implements

API Surface (6)

Map<K, V> createUnderlyingMap()
V getObject(K name)
void putObject(K key, V value)
Set<K> getKeys()
boolean containsKey(K key)
Iterator<V> iterator()

Fields & Constants (2)

logger
registryObjects

String literals (2)

"Adding duplicate key \'"
"\' to registry"

Code Graph: Dependencies (1)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

RegistrySimple.java61 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.util;
2
3
import com.google.common.collect.Maps;
4
import java.util.Collections;
5
import java.util.Iterator;
6
import java.util.Map;
7
import java.util.Set;
8
import org.apache.commons.lang3.Validate;
9
import org.apache.logging.log4j.LogManager;
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 key, V value)
31
    {
32
        Validate.notNull(key);
33
        Validate.notNull(value);
34
35
        if (this.registryObjects.containsKey(key))
36
        {
37
            logger.debug("Adding duplicate key \'" + key + "\' to registry");
38
        }
39
40
        this.registryObjects.put(key, value);
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 key)
52
    {
53
        return this.registryObjects.containsKey(key);
54
    }
55
56
    public Iterator<V> iterator()
57
    {
58
        return this.registryObjects.values().iterator();
59
    }
60
}
61

Deobfuscated MCP 1.8.9 source of RegistrySimple from Marcelektro/MavenMCP-1.8.9 (net/minecraft/util/RegistrySimple.java), stored verbatim.