Class AbstractModelGroup<M extends Model>

java.lang.Object
io.guise.framework.model.AbstractModelGroup<M>
Type Parameters:
M - The type of model contained in the group.
All Implemented Interfaces:
ModelGroup<M>
Direct Known Subclasses:
ValuePolicyModelGroup

public abstract class AbstractModelGroup<M extends Model> extends Object implements ModelGroup<M>
An abstract implementation of a group of similar models for providing such functions as communication or mutual exclusion. This class is thread safe.
Author:
Garret Wilson.
  • Constructor Details

    • AbstractModelGroup

      public AbstractModelGroup(M... 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

    • getModelSet

      protected Set<M> getModelSet()
      Returns:
      The set of models.
    • contains

      public boolean contains(Model model)
      Description copied from interface: ModelGroup
      Determines whether this group contains the given model.
      Specified by:
      contains in interface ModelGroup<M extends Model>
      Parameters:
      model - The model being checked for group inclusion.
      Returns:
      true if the model is contained in this group, else false.
    • add

      public void add(M model)
      Adds a model to the group. If the model is already included in the group, no action occurs.

      This version delegates to addImpl(Model).

      Specified by:
      add in interface ModelGroup<M extends Model>
      Parameters:
      model - The model to add to the group.
    • addImpl

      protected void addImpl(M model)
      Actual implementation of adding a model to the group.
      Parameters:
      model - The model to add to the group.
      Throws:
      NullPointerException - if the given model is null.
    • remove

      public void remove(M model)
      Removes a model from the group. If the model is not included in this group, no action occurs.

      This version delegates to removeImpl(Model).

      Specified by:
      remove in interface ModelGroup<M extends Model>
      Parameters:
      model - The model to remove from the group.
    • removeImpl

      protected void removeImpl(M model)
      Actual implementation of removing a model from the group.
      Parameters:
      model - The model to remove from the group.
      Throws:
      NullPointerException - if the given model is null.