com.guiseframework.model
Class AbstractModelGroup<M extends Model>

java.lang.Object
  extended by com.guiseframework.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 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
AbstractModelGroup(M... models)
          Model constructor.
 
Method Summary
 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)
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.
Throws:
java.lang.NullPointerException - if the given model is null.

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(M).

Specified by:
add in interface ModelGroup<M extends Model>
Parameters:
model - The model to add to the group.
Throws:
java.lang.NullPointerException - if the given model is null.

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(M).

Specified by:
remove in interface ModelGroup<M extends Model>
Parameters:
model - The model to remove from the group.
Throws:
java.lang.NullPointerException - if the given model is null.

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.


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.