Class Multiton


  • public abstract class Multiton
    extends Object
    Base class for multitons. A multiton is a class that has a fixed set of instances. The base class also provides a simple mechanism that allows to extend the behavior of a multiton using adapters.

    The set of instances of a multiton is determined by:

    • The values of all public static final fields in the multiton class that have types that are assignment compatible with the multiton class.
    • The array elements returned by methods in the multiton class annotated with Instances. These methods must be private static, have no parameters and return an array with an component type assignment compatible with the multiton class.
    • Constructor Detail

      • Multiton

        public Multiton()
    • Method Detail

      • getInstances

        public static <T extends MultitonList<T> getInstances​(Class<T> multitonClass)
        Get all instances of the given multiton. See the Javadoc of the Multiton class for information about how the instances are determined.
        Parameters:
        multitonClass - the multiton class
        Returns:
        the list of instances
        Throws:
        MultitonInstantiationException - if an error occurred
      • getAdapter

        public final <T> T getAdapter​(Class<T> type)