java.lang.Object
no.ntnu.principes.controller.screen.ScreenContextManager
Manages the creation, retrieval, and lifecycle of screen contexts associated with unique
controllers.
Provides an interface to manage contexts for screens by controller identifiers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classManages a collection ofScreenContextobjects, each identified by a unique screen ID. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears all stored screen context holders managed by this instance.voidclearContext(UUID controllerId) Removes the screen context associated with the given controller ID from the internal storage.Retrieves theScreenContextManager.ScreenContextHolderassociated with the specified controller ID.static ScreenContextManagerRetrieves the singleton instance ofScreenContextManager, ensuring that only one instance of the manager exists throughout the application lifecycle.getOrCreateHolder(UUID controllerId) Retrieves theScreenContextManager.ScreenContextHolderassociated with the specified controller ID.
-
Method Details
-
getHolder
Retrieves theScreenContextManager.ScreenContextHolderassociated with the specified controller ID. If no holder exists for the given ID, a new one is created and returned.- Parameters:
controllerId- The UUID representing the unique identifier for a screen controller. Must not be null.- Returns:
- The
ScreenContextManager.ScreenContextHolderassociated with the given controller ID. A new instance is created if none exists.
-
getInstance
Retrieves the singleton instance ofScreenContextManager, ensuring that only one instance of the manager exists throughout the application lifecycle.- Returns:
- The single
ScreenContextManagerinstance, responsible for managing screen contexts associated with unique controllers.
-
getOrCreateHolder
Retrieves theScreenContextManager.ScreenContextHolderassociated with the specified controller ID. If no holder exists for the given controller ID, a newScreenContextManager.ScreenContextHolderis created, stored, and returned.- Parameters:
controllerId- The uniqueUUIDfor the screen controller. Cannot be null. Used as a key to identify and store the corresponding holder.- Returns:
- The
ScreenContextManager.ScreenContextHolderassociated with the given controller ID. A new instance is created and stored if no holder exists for the ID. - Throws:
NullPointerException- IfcontrollerIdis null.
-
clearContext
Removes the screen context associated with the given controller ID from the internal storage. This operation effectively frees any resources held by the correspondingScreenContextHolder. If no context exists for the specified controller ID, the method does nothing.- Parameters:
controllerId- The uniqueUUIDidentifier for the screen controller to clear. Must not be null.- Throws:
NullPointerException- IfcontrollerIdis null.
-
clearAllContexts
public void clearAllContexts()Clears all stored screen context holders managed by this instance.This method removes all entries in the internal map used to store
ScreenContextHolderinstances.
-