All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.routing.alertpatch.TimePeriod Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
package org.opentripplanner.routing.alertpatch;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * Represents a period of time, in terms of seconds in [start, end)
 *
 * @author novalis
 */
public class TimePeriod {

  // TODO OTP2 - This class is used both for internal and external API representation,
  //           - a external API version should be created to decouple the internal model
  //           - from any API usage.

  public static final long OPEN_ENDED = Long.MAX_VALUE;

  @JsonSerialize
  public long startTime;

  @JsonSerialize
  public long endTime;

  public TimePeriod(long start, long end) {
    this.startTime = start;
    this.endTime = end;
  }

  public TimePeriod() {}

  public int hashCode() {
    return (int) ((startTime & 0x7fff) + (endTime & 0x7fff));
  }

  public boolean equals(Object o) {
    if (!(o instanceof TimePeriod)) {
      return false;
    }
    TimePeriod other = (TimePeriod) o;
    return other.startTime == startTime && other.endTime == endTime;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy