Enum Class InstanceMode

java.lang.Object
java.lang.Enum<InstanceMode>
org.refcodes.decoupling.InstanceMode
All Implemented Interfaces:
Serializable, Comparable<InstanceMode>, Constable, InstanceMetrics

public enum InstanceMode extends Enum<InstanceMode> implements InstanceMetrics
The InstanceMode describes how an instance for a Dependency is managed (instantiated).
  • Enum Constant Details

    • SINGLETON_BY_DEFAULT

      public static final InstanceMode SINGLETON_BY_DEFAULT
      Technically identical to SINGLETON_IS_MANDATORY with emphasizing on the semantics of being a default Dependency, usually used by (sub-classes of) the Reactor type to emphasize that the Dependency is part of the implementation (singleton = yes, required = yes).
    • SINGLETON_IS_MANDATORY

      public static final InstanceMode SINGLETON_IS_MANDATORY
      Just a single instance is required and created in any case, not only when when demanded by other dependencies, no matter how often the instance is being demanded (singleton = yes, required = yes).
    • INSTANCE_IS_MANDATORY

      public static final InstanceMode INSTANCE_IS_MANDATORY
      At least one instance is required and created in any case, not only when being demanded, though each time an instance is demanded(!) by other dependencies, a new instance is returned (the first time an instance is demanded, the initially created instance is injected, singleton = false, required = yes).
    • SINGLETON_ON_DEMAND

      public static final InstanceMode SINGLETON_ON_DEMAND
      Just a single instance is created on demanded(!) by other dependencies, no matter how often the instance is being demanded (singleton = yes, required = no).
    • INSTANCE_ON_DEMAND

      public static final InstanceMode INSTANCE_ON_DEMAND
      Each time an instance is demanded(!) by other dependencies, a new instance is returned (singleton = no, required = no).
  • Method Details

    • values

      public static InstanceMode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static InstanceMode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isSingleton

      public boolean isSingleton()
      True in case the Dependency represents a singleton.
      Specified by:
      isSingleton in interface InstanceMetrics
      Returns:
      True in case of being a singleton Dependency.
    • isMandatory

      public boolean isMandatory()
      True in case a Dependency is required to be instantiated in any case, even if not being demanded by another dependency.
      Specified by:
      isMandatory in interface InstanceMetrics
      Returns:
      True in case of being a required Dependency.
    • toSingletonModes

      public static InstanceMetrics[] toSingletonModes()
      Retrieves all InstanceMode elements representing a singleton.
      Returns:
      The singleton elements.
    • toRequiredModes

      public static InstanceMetrics[] toRequiredModes()
      Retrieves all InstanceMode elements representing a required instances.
      Returns:
      The required instances elements.