//----------------------------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.condition;

import org.huihoo.workflow.WorkflowSerializable;


public class ConditionType implements WorkflowSerializable
{
	public final static ConditionType CONDITION_SCRIPT     = new ConditionType("CONDITION_SCRIPT");
	public final static ConditionType CONDITION_XCDATA     = new ConditionType("CONDITION_XCDATA");
	
	private String type;

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

	public String getType()
	{
		return type;
	}

	public static ConditionType parse(String type)
	{	
		if ("CONDITION_SCRIPT".equals(type))
		{
			return CONDITION_SCRIPT;
		}
		else if ("CONDITION_XCDATA".equals(type))
		{
			return CONDITION_XCDATA;
		}	
			
		//default value is CONDITION_XCDATA
		return CONDITION_XCDATA;
	}

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

		if (obj instanceof ConditionType)
		{
			ConditionType anotherCT = (ConditionType) obj;

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

		return false;
	}

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