Package net.paulem.arcana.registry
Class NewFrozenRegistry<T extends RegistryKey<K>,K>
java.lang.Object
net.paulem.arcana.registry.AbstractRegistry<T,K>
net.paulem.arcana.registry.WriteableRegistry<T,K>
net.paulem.arcana.registry.NewFrozenRegistry<T,K>
- Type Parameters:
T- The type of objects stored in the registry, which must implementRegistryKey.K- The key type used to identify objects in the registry.
- All Implemented Interfaces:
Registry<T,K>
A registry that can be frozen, preventing any further registrations.
This is useful for registries that should not change after a certain point.
-
Field Summary
Fields inherited from class net.paulem.arcana.registry.AbstractRegistry
registry -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class net.paulem.arcana.registry.AbstractRegistry
get, getOrDefault, getOrDefault, getOrNull, getOrThrow, keys
-
Constructor Details
-
NewFrozenRegistry
Creates a new, unfrozen registry, copying the entries from the map produced by the given supplier.- Parameters:
registrySupplier- supplies the map whose entries are copied into this registry
-
NewFrozenRegistry
public NewFrozenRegistry()Creates a new, empty, unfrozen registry backed by aHashMap.
-
-
Method Details
-
freeze
public void freeze()Freezes this registry, preventing any further registrations.- Throws:
IllegalStateException- if the registry is already frozen
-
register
Registers an object within the registry- Overrides:
registerin classWriteableRegistry<T extends RegistryKey<K>,K> - Parameters:
object- the object to register- Returns:
- true if the value was successfully registered, otherwise false.
- Throws:
IllegalStateException- if this registry has already been frozen viafreeze()
-