"To Many"-Association


/**
 * <pre>
 *                                   n
 * LeftClass -------------------------- RightClass
 *                          rightRoles
 * </pre>
 */
Attribute
private FHashSet rightRoles;

or

private FTreeSet rightRoles;

or

private FLinkedList rightRoles;

 
Access Methods Summary
public boolean hasInRightRoles (RightClass value)
public Iterator iteratorOfRightRoles ()
public int sizeOfRightRoles ()
public boolean addToRightRoles (RightClass value)
public boolean removeFromRightRoles (RightClass value)
public boolean removeAllFromRightRoles ()
 
Access Methods

public boolean hasInRightRoles (RightClass value)
{
return ((this.rightRoles != null) && (value != null) && this.rightRoles.contains (value));
}

public Iterator iteratorOfRightRoles ()
{
return ((this.rightRoles == null) ? FEmptyIterator.get () : this.rightRoles.iterator ());
}

public int sizeOfRightRoles ()
{
return ((this.rightRoles == null) ? 0 : this.rightRoles.size ());
}

public boolean addToRightRoles (RightClass value)
{
boolean changed = false; if (value != null [&& !hasInRightRoles (value)]) { if (this.rightRoles == null) { this.rightRoles = new FHashSet ($CONSTRUCTORPARAM$); // or FTreeSet () or FLinkedList () } changed = this.rightRoles.add (value); if (changed) { value.<method to insert>; } } return changed;
}

public boolean removeFromRightRoles (RightClass value)
{
boolean changed = false; if ((this.rightRoles != null) && (value != null)) { changed = this.rightRoles.remove (value); if (changed) { value.<method to remove>; } } return changed;
}

public void removeAllFromRightRoles ()
{
RightClass tmpValue; Iterator iter = this.iteratorOfRightRoles (); while (iter.hasNext ()) { tmpValue = (RightClass) iter.next (); this.removeFromRightRoles (tmpValue); }
}
 
Comment
Using a "To Many" association in conjunction with a Qualified "To One" or "To Many" association would lead to the following signatures:

public boolean addToRightRoles (KeyType key, RightClass value)
public boolean removeFromRightRoles (KeyType key, RightClass value)

<method to remove> = removeFromLeftRoles (key, this);
<method to insert> = addToLeftRoles (key, this);