package de.dhbwstuttgart.bytecode.constraint;

public class TPHConstraint {
	protected String left;
	protected String right;
	protected Relation rel;
	public enum Relation{
		EXTENDS, EQUAL
	}
	
	public TPHConstraint(String left, String right, Relation rel) {
		this.left = left;
		this.right = right;
		this.rel = rel;
	}
	
	public String getLeft() {
		return left;
	}


	public String getRight() {
		return right;
	}


	public Relation getRel() {
		return rel;
	}
	
	public void setLeft(String left) {
		this.left = left;
	}

	public void setRight(String right) {
		this.right = right;
	}

	public void setRel(Relation rel) {
		this.rel = rel;
	}
	
	public boolean containTPH(String tph) {
		return left.equals(tph)||right.equals(tph);
	}
	
	public boolean equalConstraint(TPHConstraint constraint) {
		return rel == constraint.getRel() && left.equals(constraint.getLeft()) && right.equals(constraint.getRight());
	}
	
	@Override
	public String toString() {
		if(rel == Relation.EXTENDS) {
			return left + " < " + right;
		}else {
			return left + " = " + right;
		}
	}
}
