/**
 * 
 */
package de.dhbwstuttgart.bytecode.genericsGeneratorTypes;

import java.util.List;

import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;

/**
 * @author fayez
 *
 */
public class Cycle {
	private final List<TPHConstraint> constraints;

	/**
	 * @param constraints
	 */
	public Cycle(List<TPHConstraint> constraints) {
		this.constraints = constraints;
	}

	/**
	 * @return the constraints
	 */
	public List<TPHConstraint> getConstraints() {
		return constraints;
	}

	public boolean containConstraint(TPHConstraint constraint) {
		for(TPHConstraint c : constraints) {
			if(c.equalConstraint(constraint))
				return true;
		}
		return false;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		constraints.forEach(c->sb.append(c.getLeft()+" -> "));
		sb.append(constraints.get(constraints.size()-1).getRight());
		return sb.toString();
	}
}
