//----------------------------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 SplitType implements WorkflowSerializable
{
	public final static SplitType SPLIT_AND = new SplitType("AND");
	public final static SplitType SPLIT_OR  = new SplitType("OR");  
	public final static SplitType SPLIT_XOR = new SplitType("XOR");
  
	public final static SplitType SPLIT_UNKNOWN  = new SplitType("UNKNOWN");

  
	private String type;
  
	private SplitType(String type)
	{
		this.type=type;
	}
  
	public String getType()
	{
		return type;
	}
  
	public boolean equals(Object obj)
	{
		if (this == obj) 
		{
			return true;
		}
  
		if (obj instanceof SplitType) 
		{
			SplitType anotherST = (SplitType)obj;
      
			if(anotherST.getType().equals(type))
			{
				return true;
			}      
		}
    
		return false;
	}
  
	public String toString()
	{
		return "SplitType@" + type;
	}
	
	public static SplitType parse(String type)
	{
		if("AND".equals(type))
		{
			return SPLIT_AND;
		}
		else if("OR".equals(type))
		{
			return SPLIT_OR;
		}
		else if("XOR".equals(type))
		{
			return SPLIT_XOR;
		}
    
		return SPLIT_UNKNOWN;
	}
}