package de.dhbwstuttgart.typeinference.constraints;

import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class Constraint<A> extends HashSet<A> implements Comparable<Constraint<A>> {
	private static final long serialVersionUID = 1L;
	private Boolean isInherited = false;//wird beides nur für die Method-Constraints benoetigt
	private Boolean isImplemented = false;
	
	/*
	 * wird verwendet um bei der Codegenerierung die richtige Methoden - Signatur
	 * auszuwaehlen 
	 */
	/*private*/ Set<A> methodSignatureConstraint = new HashSet<>();
	
	private Constraint<A> extendConstraint = null;
	
	public Constraint() {
		super();
	}
	
	public Constraint(Boolean isInherited, Boolean isImplemented) {
		this.isInherited = isInherited;
		this.isImplemented = isImplemented;
	}
	
	public Constraint(Boolean isInherited, Boolean isImplemented, Constraint<A> extendConstraint, Set<A> methodSignatureConstraint) {
		this.isInherited = isInherited;
		this.isImplemented = isImplemented;
		this.extendConstraint = extendConstraint;
		this.methodSignatureConstraint = methodSignatureConstraint;
	}
	
	public void setIsInherited(Boolean isInherited) {
		this.isInherited = isInherited;
	}
	
	public Boolean isInherited() {
		return isInherited;
	}
	
	public Boolean isImplemented() {
		return isImplemented;
	}
	
	public Constraint<A> getExtendConstraint() {
		return extendConstraint;
	}
	
	public void setExtendConstraint(Constraint<A> c) {
		extendConstraint = c;
	}
	
	public Set<A> getmethodSignatureConstraint() {
		return methodSignatureConstraint;
	}
	
	public void setmethodSignatureConstraint(Set<A> c) {
		methodSignatureConstraint = c;
	}

	public String toString() {
		return super.toString() + "\nisInherited = " + isInherited + " isOveridden = " + isImplemented
				+ methodSignatureConstraint
				//" + extendsContraint: "  + (extendConstraint != null ? extendConstraint.toStringBase() : "null" ) 
				+ "\n" ;
	}
	
	public String toStringBase() {
		return super.toString();
	}

	@Override
	public int compareTo(Constraint<A> o) {
		return this.toString().compareTo(o.toString());
	}
}
