Class StructureRegistry
java.lang.Object
nl.pim16aap2.animatedarchitecture.core.structures.StructureRegistry
- All Implemented Interfaces:
IDebuggable,StructureDeletionManager.IDeletionListener
@Singleton
public final class StructureRegistry
extends Object
implements IDebuggable, StructureDeletionManager.IDeletionListener
Represents a registry of structures.
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionGets the debug information for this object.getRegisteredStructure(long structureUID) Attempts to get theStructureassociated the given UID.booleanisRegistered(long structureUID) Checks if aStructureassociated with a given UID has been registered.booleanisRegistered(Structure structure) Checks if the exact instance of the providedStructurehas been registered.voidonStructureDeletion(IStructureConst structure) Called when a structure is deleted.putIfAbsent(Structure structure) Puts a newStructurein the cache if it does not exist yet.static StructureRegistryunCached(DebuggableRegistry debuggableRegistry, StructureDeletionManager structureDeletionManager) Creates a newStructureRegistrywithout any caching.
-
Field Details
-
CACHE_EXPIRY
-
-
Method Details
-
unCached
public static StructureRegistry unCached(DebuggableRegistry debuggableRegistry, StructureDeletionManager structureDeletionManager) Creates a newStructureRegistrywithout any caching.- Returns:
- The new
StructureRegistry.
-
onStructureDeletion
Description copied from interface:StructureDeletionManager.IDeletionListenerCalled when a structure is deleted.- Specified by:
onStructureDeletionin interfaceStructureDeletionManager.IDeletionListener- Parameters:
structure- The structure that was deleted.
-
getRegisteredStructure
Attempts to get theStructureassociated the given UID. It can only retrieve doors that still exist in the cache.- Parameters:
structureUID- The UID of the structure.- Returns:
- The
Structureif it has been retrieved from the database.
-
isRegistered
public boolean isRegistered(long structureUID) Checks if aStructureassociated with a given UID has been registered.- Parameters:
structureUID- The UID of the structure.- Returns:
- True if an entry exists for the
Structurewith the given UID.
-
isRegistered
Checks if the exact instance of the providedStructurehas been registered. (i.e. it uses '==' to check if the cached entry is the same).- Parameters:
structure- The structure.- Returns:
- True if an entry exists for the exact instance of the provided
Structure.
-
putIfAbsent
Puts a newStructurein the cache if it does not exist yet.- Parameters:
structure- The structure to put in the cache.- Returns:
- An empty
Optionalif the structure was successfully put in the cache. If a mapping already existed, the old structure will be returned instead.
-
getDebugInformation
Description copied from interface:IDebuggableGets the debug information for this object.- Specified by:
getDebugInformationin interfaceIDebuggable- Returns:
- The debug information or null if there's nothing to log at this time.
-