//----------------------------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 ActivityType implements WorkflowSerializable
{
	
		public final static ActivityType ACTIVITY_BEGIN          = new ActivityType("ACTIVITY_BEGIN");
		public final static ActivityType ACTIVITY_END            = new ActivityType("ACTIVITY_END");
		
		public final static ActivityType ACTIVITY_SUBFLOW        = new ActivityType("ACTIVITY_SUBFLOW");
	  public final static ActivityType ACTIVITY_ROUTE          = new ActivityType("ACTIVITY_ROUTE");	
	
		public final static ActivityType ACTIVITY_BUSINESS       = new ActivityType("ACTIVITY_BUSINESS");
	  //public final static ActivityType ACTIVITY_UNKNOWN        = new ActivityType("ACTIVITY_UNKNOWN");
	
		private String type;

		private ActivityType(String type)
		{
			this.type = type;
		}

		public String getType()
		{
			return type;
		}

		public static ActivityType parse(String type)
		{	
			if ("ACTIVITY_BEGIN".equals(type))
			{
				return ACTIVITY_BEGIN;
			}
			else if ("ACTIVITY_END".equals(type))
			{
				return ACTIVITY_END;
			}
			else if ("ACTIVITY_SUBFLOW".equals(type))
			{
				return ACTIVITY_SUBFLOW;
			}
			else if ("ACTIVITY_ROUTE".equals(type))
			{
				return ACTIVITY_ROUTE;
			}	
			else if ("ACTIVITY_BUSINESS".equals(type))
			{
				return ACTIVITY_BUSINESS;
			}
			
			//default value is ACTIVITY_BUSINESS
			return ACTIVITY_BUSINESS;
		}

		public boolean equals(Object obj)
		{
			if (this == obj)
			{
				return true;
			}

			if (obj instanceof ActivityType)
			{
				ActivityType anotherAT = (ActivityType) obj;

				if (anotherAT.getType().equals(type))
				{
					return true;
				}
			}

			return false;
		}

		public String toString()
		{
			return "ActivityType@" + type;
		}
}
