package jetbrains.mps.lang.test.matcher;

/*Generated by MPS */

import org.jetbrains.mps.openapi.language.SContainmentLink;

/*package*/ class ChildrenCountDifference extends DifferenceItem {
  private final SContainmentLink myRole;
  private final int myActualCount;
  private final int myExpectedCount;

  public ChildrenCountDifference(SContainmentLink role, int actualCount, int expectedCount) {
    myRole = role;
    myActualCount = actualCount;
    myExpectedCount = expectedCount;
  }

  @Override
  public String toString() {
    return "Different children count in role: " + myRole + " [was: " + myActualCount + ", expected: " + myExpectedCount + "]";
  }

  @Override
  public int hashCode() {
    return myRole.hashCode() + myActualCount * 31 + myExpectedCount * 37;
  }

  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (!(obj instanceof ChildrenCountDifference)) {
      return false;
    }
    ChildrenCountDifference diff = (ChildrenCountDifference) obj;
    return myRole.equals(diff.myRole) && myActualCount == diff.myActualCount && myExpectedCount == diff.myExpectedCount;
  }
}
