Class MutualExclusionPolicyModelGroup

  • All Implemented Interfaces:
    com.globalmentor.beans.GenericPropertyChangeListener<java.lang.Boolean>, ModelGroup<ValueModel<java.lang.Boolean>>, java.beans.PropertyChangeListener, java.util.EventListener

    public final class MutualExclusionPolicyModelGroup
    extends ValuePolicyModelGroup<java.lang.Boolean>
    A group that ensures that only one boolean model in the group is set to true at the same time.

    This class is declared final because it represents a particular defined semantics, no more and no less. This allows controllers to make assumptions about models with only this listener, and offload mutual exclusion to client that have this capability built in.

    The current implementation will only update the selected model for models that are already a part of the group.

    Author:
    Garret Wilson.
    • Constructor Detail

      • MutualExclusionPolicyModelGroup

        public MutualExclusionPolicyModelGroup()
        Default constructor. Provided to prevent array of generic types warning.
      • MutualExclusionPolicyModelGroup

        public MutualExclusionPolicyModelGroup​(ValueModel<java.lang.Boolean>... models)
        Model constructor.
        Parameters:
        models - Zero or more models with which to initially place in the group.
        Throws:
        java.lang.NullPointerException - if one of the models is null.
    • Method Detail

      • getSelectedModel

        public ValueModel<java.lang.Boolean> getSelectedModel()
        Returns:
        The currently selected model.
      • propertyChange

        public void propertyChange​(com.globalmentor.beans.GenericPropertyChangeEvent<java.lang.Boolean> propertyChangeEvent)