@Override
  public int compareTo(Interval<T> other) {
    if (lowerLimit() == null) {
      return other.lowerLimit() == null ? 0 : -1;
    }
    if (upperLimit() == null) {
      return other.upperLimit() == null ? 0 : 1;
    }
    if (!upperLimit().equals(other.upperLimit())) {
      return upperLimit().compareTo(other.upperLimit());
    }
    if (includesLowerLimit() && !other.includesLowerLimit()) {
      return -1;
    }
    if (!includesLowerLimit() && other.includesLowerLimit()) {
      return 1;
    }
    return lowerLimit().compareTo(other.lowerLimit());
  }