package soot.poc.inter;

import soot.SootField;
import soot.Unit;

public class Definition
{
	private SootField field;
	private Unit defStatement;
	
	public Definition(SootField field, Unit statement)
	{
		this.field = field;
		this.defStatement = statement;
	}
	
	public SootField getField()
	{
		return this.field;
	}
	
	public Unit getDefStatement()
	{
		return this.defStatement;
	}
	
	public void setField(SootField variable)
	{
		this.field = variable;
	}
	
	public void setDefStatement(Unit statement)
	{
		this.defStatement = statement;
	}
	
	public boolean defines(SootField variable)
	{
		return this.field.equals(variable);
	}
	
	@Override
	public boolean equals(Object obj)
	{
		boolean ret = false;
		if (obj != null)
		{
			if (obj instanceof Definition)
			{
				ret = this.field.equals(((Definition)obj).getField())
						&& this.defStatement.equals(((Definition)obj).getDefStatement());
			}
		}
		return ret;
	}
	
	@Override
	public String toString()
	{
		return this.field.getSignature() + "@{" + this.defStatement.toString() + "}";
	}
}
