Class MutualExclusionPolicyModelGroup

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

public final class MutualExclusionPolicyModelGroup extends ValuePolicyModelGroup<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 Details

    • MutualExclusionPolicyModelGroup

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

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

    • getSelectedModel

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

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