/*
 * Created on 2004-2-11
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package workflow.wfmc.xpdl.activity;

import workflow.WorkflowInterface;
/**
 * @author zosatapo
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class JoinType implements WorkflowInterface
{
	public final static JoinType JOIN_AND    = new JoinType("AND");
	public final static JoinType JOIN_XOR    = new JoinType("XOR");
	public final static JoinType JOIN_OR     = new JoinType("OR");
	public final static JoinType JOIN_WEIGHT = new JoinType("WEIGHT");

	//for shared route (just used to predigest process)
	public final static JoinType JOIN_ROUTE = new JoinType("ROUTE");

	//used for activity multi-instance (i.e meeting signature)
	public final static JoinType JOIN_INSTANCE_AND = new JoinType("INSTANCE_AND");
	public final static JoinType JOIN_INSTANCE_XOR = new JoinType("INSTANCE_XOR");
	public final static JoinType JOIN_INSTANCE_WEIGHT = new JoinType("INSTANCE_WEIGHT");

	public final static JoinType JOIN_NA = new JoinType("NA");

	private String type;

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

	public String getType()
	{
		return type;
	}

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

		if (obj instanceof JoinType)
		{
			JoinType anotherJT = (JoinType) obj;

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

		return false;
	}

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

	public static JoinType parse(String type)
	{
		if ("AND".equals(type))
		{
			return JOIN_AND;
		}
		else if ("XOR".equals(type))
		{
			return JOIN_XOR;
		}
		else if ("WEIGHT".equals(type))
		{
			return JOIN_WEIGHT;
		}
		else if ("OR".equals(type))
		{
			return JOIN_OR;
		}
		else if ("ROUTE".equals(type))
		{
			return JOIN_ROUTE;
		}
		else if ("INSTANCE_AND".equals(type))
		{
			return JOIN_INSTANCE_AND;
		}
		else if ("INSTANCE_XOR".equals(type))
		{
			return JOIN_INSTANCE_XOR;
		}
		else if ("INSTANCE_WEIGHT".equals(type))
		{
			return JOIN_INSTANCE_WEIGHT;
		}

		return JOIN_NA;
	}
}
