//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE----------------------------
package org.huihoo.workflow.xpdl.activity;

import org.huihoo.workflow.WorkflowSerializable;

public class PerformerMode implements WorkflowSerializable
{
	public static final PerformerMode  SINGLE_SELECTION       = new PerformerMode("SINGLE_SELECTION");
	public static final PerformerMode  MULTIPLE_SELECTION     = new PerformerMode("MULTIPLE_SELECTION");
	public static final PerformerMode  WHOLE_SELECTION     = new PerformerMode("WHOLE_SELECTION");
	
	private String mode;

	private PerformerMode(String mode)
	{
		this.mode = mode;
	}

	public String getMode()
	{
		return mode;
	}

	public static PerformerMode parse(String mode)
	{	
		if ("SINGLE_SELECTION".equals(mode))
		{
			return SINGLE_SELECTION;
		}
		else if ("MULTIPLE_SELECTION".equals(mode))
		{
			return MULTIPLE_SELECTION;
		}
		else if ("WHOLE_SELECTION".equals(mode))
		{
			return WHOLE_SELECTION;
		}
				
		return WHOLE_SELECTION;
	}
	
	public boolean equals(Object obj)
	{
		if (this == obj)
		{
			return true;
		}

		if (obj instanceof PerformerMode)
		{
			PerformerMode anotherPM = (PerformerMode) obj;

			if (anotherPM.getMode().equals(mode))
			{
				return true;
			}
		}

		return false;
	}

	public String toString()
	{
		return "PerformerMode@" + mode;
	}
}
