Class AbstractModelGroup<M extends Model>

  • 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 java.lang.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 Summary

      Constructors 
      Constructor Description
      AbstractModelGroup​(M... models)
      Model constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(M model)
      Adds a model to the group.
      protected void addImpl​(M model)
      Actual implementation of adding a model to the group.
      boolean contains​(Model model)
      Determines whether this group contains the given model.
      protected java.util.Set<M> getModelSet()  
      void remove​(M model)
      Removes a model from the group.
      protected void removeImpl​(M model)
      Actual implementation of removing a model from the group.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractModelGroup

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

      • getModelSet

        protected java.util.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:
        java.lang.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:
        java.lang.NullPointerException - if the given model is null.