package de.dhbwstuttgart.strucTypes5.constraints;

import de.dhbwstuttgart.strucTypes5.typeVars.TypeVarAbstract;

/**
 * Created by sebastian on 02.05.17.
 */
public class ConstraintInterface extends ConstraintAbstract {

    private TypeVarAbstract SubType;
    private TypeVarAbstract SuperType;

    public ConstraintInterface(TypeVarAbstract subType, TypeVarAbstract superType) {
        SubType = subType;
        SuperType = superType;
    }


    public TypeVarAbstract getSubType() {
        return SubType;
    }

    public void setSubType(TypeVarAbstract subType) {
        SubType = subType;
    }

    public TypeVarAbstract getSuperType() {
        return SuperType;
    }

    public void setSuperType(TypeVarAbstract superType) {
        SuperType = superType;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ConstraintInterface)) return false;

        ConstraintInterface that = (ConstraintInterface) o;

        if (getSubType() != null ? !getSubType().equals(that.getSubType()) : that.getSubType() != null) return false;
        return getSuperType() != null ? getSuperType().equals(that.getSuperType()) : that.getSuperType() == null;
    }

    @Override
    public int hashCode() {
        int result = getSubType() != null ? getSubType().hashCode() : 0;
        result = 31 * result + (getSuperType() != null ? getSuperType().hashCode() : 0);
        return result;
    }


    //
    @Override
    public String toString() {
        return String.format("ConstraintInterface(  %s <* %s ) " , getSubType(), getSuperType());
    }
}
