package cz.seznam.euphoria.core.client.dataset.windowing;

import java.io.Serializable;
import java.util.Objects;

public final class TimeInterval implements Serializable {
  private final long startMillis;
  private final long intervalMillis;

  public TimeInterval(long startMillis, long intervalMillis) {
    this.startMillis = startMillis;
    this.intervalMillis = intervalMillis;
  }

  public long getStartMillis() {
    return startMillis;
  }

  public long getEndMillis() {
    return startMillis + intervalMillis;
  }

  public long getIntervalMillis() {
    return intervalMillis;
  }

  @Override
  public boolean equals(Object o) {
    if (o instanceof TimeInterval) {
      TimeInterval that = (TimeInterval) o;
      return this.startMillis == that.startMillis
          && this.intervalMillis == that.intervalMillis;
    }
    return false;
  }

  @Override
  public int hashCode() {
    return Objects.hash(startMillis, intervalMillis);
  }

  @Override
  public String toString() {
    return "TimeInterval{" +
        "startMillis=" + startMillis +
        ", intervalMillis=" + intervalMillis +
        '}';
  }
}
@@ -1,8 +1,9 @@
+%0A
 package 
@@ -164,16 +164,42 @@
 alizable
+, Comparable%3CTimeInterval%3E
  %7B%0A  pri
@@ -1152,10 +1152,228 @@
 '%7D';%0A  %7D
+%0A%0A  @Override%0A  public int compareTo(TimeInterval o) %7B%0A    long cmp = startMillis - o.startMillis;%0A    if (cmp != 0) %7B%0A      return cmp %3C 0 ? -1 : 1;%0A    %7D%0A    return intervalMillis - o.intervalMillis %3C 0 ? -1 : 1;%0A  %7D
 %0A%7D

#! TimeInterval is Comparable