package de.snailshell.consensus.demo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;

import de.uka.ipd.consensus.foundation.schema.Association;
import de.uka.ipd.consensus.foundation.schema.AssociationRole;
import de.uka.ipd.consensus.foundation.schema.User;

/**
 * @author Thomas Much
 * @version 2006-06-14
 */
public class AssociationBean {
	
	private Association association;
	private Collection  roleBeans = Collections.EMPTY_SET;

	
	public AssociationBean(User user, Association association) {
		this.association = association;
		
		Collection c = association.getAssociationRoles( user );

		if (!c.isEmpty()) {
			roleBeans = new ArrayList(10);
			
			Iterator it = c.iterator();
			
			while (it.hasNext()) {
				AssociationRole ar = (AssociationRole)it.next();

				RoleBean rb = new RoleBean( user, ar );
				
				roleBeans.add( rb );
			}
		}
	}


	public Association getAssociation() {
		return this.association;
	}


	public Collection getRoleBeans() {
		return this.roleBeans;
	}

}
