Class NewFrozenRegistry<T extends RegistryKey<K>,K>

Type Parameters:
T - The type of objects stored in the registry, which must implement RegistryKey.
K - The key type used to identify objects in the registry.
All Implemented Interfaces:
Registry<T,K>

public class NewFrozenRegistry<T extends RegistryKey<K>,K> extends WriteableRegistry<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.
  • Constructor Details

    • NewFrozenRegistry

      public NewFrozenRegistry(Supplier<Map<K,T>> registrySupplier)
      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 a HashMap.
  • Method Details

    • freeze

      public void freeze()
      Freezes this registry, preventing any further registrations.
      Throws:
      IllegalStateException - if the registry is already frozen
    • register

      public boolean register(@NotNull T object)
      Registers an object within the registry
      Overrides:
      register in class WriteableRegistry<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 via freeze()