Class Registry<T>
java.lang.Object
com.github.darksoulq.abyssallib.server.registry.Registry<T>
- Type Parameters:
T- The type of object being registered.
A generic registry system for managing library objects and their associated unique identifiers.
The registry uses a BiMap to ensure that every object has exactly one ID and every ID
points to exactly one object. This is essential for consistent serialization and lookup
across the library.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleanChecks if a specific ID is currently present in the registry.Retrieves an object from the registry by its identifier.getAll()Returns an unmodifiable view of all entries currently in the registry.Retrieves the unique identifier associated with a registered object instance.voidRegisters a new object with a unique identifier.Removes an entry from the registry by its ID.
-
Constructor Details
-
Registry
public Registry()
-
-
Method Details
-
register
Registers a new object with a unique identifier.If the ID is already present in the registry, the registration is rejected and a severe error is logged to the console to prevent accidental overwrites.
- Parameters:
id- The unique string identifier for the object.object- The object instance to register.
-
get
-
getId
-
contains
Checks if a specific ID is currently present in the registry.- Parameters:
id- The identifier to check.- Returns:
trueif an entry exists for the given ID.
-
getAll
-
remove
Removes an entry from the registry by its ID.Warning: This method is intended for internal use only. Removing entries from a registry at runtime can cause significant issues with existing data references and serialization.
- Parameters:
id- The ID of the entry to remove.- Returns:
- The object that was removed, or
nullif the ID was not found.
-
clear
@Internal public void clear()
-