Module aeonics.core

Class Manager<T extends Manager.Type>

  • Type Parameters:
    T - The manager entity type

    public abstract class Manager<T extends Manager.Type>
    extends Item<T>
    This class acts as a central registry for entities that must have only one authoritative instance. It is used typically for application-wide cross cutting concerns.

    As an entity, it represents a class that can only exists once in the system. All Manager instances must extend this class and should be registered using set(Class, Type).

    All Manager Type instances are considered internal and will never be affected by a snapshot or restore operation. This means that managers must not have own instance parameters. If needed, use config parameters instead.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Manager.Type
      Basic manager entity superclass
    • Constructor Summary

      Constructors 
      Constructor Description
      Manager()  
    • Constructor Detail

      • Manager

        public Manager()
    • Method Detail

      • of

        public static <T extends Manager.Type> T of​(java.lang.Class<T> type)
        Returns the instance of the specified manageable type
        Type Parameters:
        T - the manageable type
        Parameters:
        type - the manager type
        Returns:
        the instance of the specified entity type, or null if none was registered
      • set

        public static <T extends Manager.Type> T set​(java.lang.Class<T> type,
                                                     T instance)
        Sets the instance of the specified manager type. The instance must not be null.
        Type Parameters:
        T - the manageable instance type
        Parameters:
        type - the manageable type
        instance - the instance
        Returns:
        the instance that has been set
        Throws:
        java.lang.RuntimeException - if another instance is already registered for this entity type
        java.lang.IllegalArgumentException - if the instance is not an instance of the specified entity type
      • remove

        public static <T extends Manager.Type> void remove​(java.lang.Class<T> type)
        Removes the instance of a manageable type
        Type Parameters:
        T - the manageable type
        Parameters:
        type - the manageable type
      • replace

        public static <T extends Manager.Type> T replace​(java.lang.Class<T> type,
                                                         T instance)
        Replaces the instance of the specified entity type. The instance must not be null.
        Type Parameters:
        T - the manageable instance type
        Parameters:
        type - the entity type
        instance - the instance
        Returns:
        the instance that has been set
        Throws:
        java.lang.IllegalArgumentException - if the instance is not an instance of the specified entity type
      • all

        public static java.lang.Iterable<Manager.Type> all()
        Returns an iterator over all managers
        Returns:
        a manager iterator
      • category

        protected java.lang.Class<? extends Manager<T>> category()
        Description copied from class: Item
        Returns the target entity category. This method should be implemented by subclasses to specify the entity category.
        Specified by:
        category in class Item<T extends Manager.Type>
        Returns:
        the target entity category