/*
 * $Id: Group.java,v 1.3 2003/06/03 13:49:36 egli Exp $
 * <License>
 * The Apache Software License
 *
 * Copyright (c) 2002 lenya. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. All advertising materials mentioning features or use of this
 *    software must display the following acknowledgment: "This product
 *    includes software developed by lenya (http://www.lenya.org)"
 *
 * 4. The name "lenya" must not be used to endorse or promote products
 *    derived from this software without prior written permission. For
 *    written permission, please contact contact@lenya.org
 *
 * 5. Products derived from this software may not be called "lenya" nor
 *    may "lenya" appear in their names without prior written permission
 *    of lenya.
 *
 * 6. Redistributions of any form whatsoever must retain the following
 *    acknowledgment: "This product includes software developed by lenya
 *    (http://www.lenya.org)"
 *
 * THIS SOFTWARE IS PROVIDED BY lenya "AS IS" WITHOUT ANY WARRANTY EXPRESS
 * OR IMPLIED, INCLUDING THE WARRANTY OF NON-INFRINGEMENT AND THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 * lenya WILL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY YOU AS A RESULT
 * OF USING THIS SOFTWARE. IN NO EVENT WILL lenya BE LIABLE FOR ANY SPECIAL,
 * INDIRECT OR CONSEQUENTIAL DAMAGES OR LOST PROFITS EVEN IF lenya HAS BEEN
 * ADVISED OF THE POSSIBILITY OF THEIR OCCURRENCE. lenya WILL NOT BE LIABLE
 * FOR ANY THIRD PARTY CLAIMS AGAINST YOU.
 *
 * Lenya includes software developed by the Apache Software Foundation, W3C,
 * DOM4J Project, BitfluxEditor and Xopus.
 * </License>
 */
 
package org.apache.lenya.cms.ac;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * @author egli
 * 
 * 
 */
public class Group {
	
	private String name;
	protected Set roles = new HashSet();
	protected Set users = new HashSet();

	public Group(String name) {
		this.name = name;
	}
	
	/**
	 * Get the name of this group
	 * 
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * Get all roles of this group
	 * 
	 * @return 
	 */
	public Iterator getRoles() {
		return roles.iterator();
	}

	public Iterator getUsers() {
		return users.iterator();
	}
	
	/**
	 * Set the name of this group
	 * 
	 * @param string
	 */
	public void setName(String string) {
		name = string;
	}
	
	/**
	 * Add a role to this group
	 * 
	 * @param role
	 */
	public void addRole(Role role) {
        assert role != null;
		roles.add(role);
		role.addGroup(this);
	}
	
	/**
	 * Remove a role from this group
	 * 
	 * @param role
	 */
	public void removeRole(Role role) {
		roles.remove(role);
		role.removeGroup(this);
	}
	
	public void addUser(User user) {
		users.add(user);
	}
	
	public void removeUser(User user) {
		users.remove(user);
	}
	
}

@@ -19,17 +19,17 @@
 ava,v 1.
-3
+4
  2003/06
@@ -37,15 +37,15 @@
 03 1
-3:49:36
+6:37:39
  egl
@@ -3314,10 +3314,348 @@
 );%0A%09%7D%0A%09%0A
+%09/* (non-Javadoc)%0A%09 * @see java.lang.Object#equals(java.lang.Object)%0A%09 */%0A%09public boolean equals(Object obj) %7B%0A%09%09if (obj instanceof Group) %7B%0A%09%09%09return getName().equals(((Group) obj).getName());%0A%09%09%7D%0A%09%09return false;%0A%09%7D%0A%0A%09/* (non-Javadoc)%0A%09 * @see java.lang.Object#hashCode()%0A%09 */%0A%09public int hashCode() %7B%0A%09%09return getName().hashCode();%0A%09%7D%0A%0A
 %7D%0A

Add equals and hashcode methods.