MATSIM
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
org.matsim.facilities.OpeningTimeImpl Class Reference
Inheritance diagram for org.matsim.facilities.OpeningTimeImpl:
Inheritance graph
[legend]

Public Member Functions

 OpeningTimeImpl (final double startTime, final double endTime)
 
int compareTo (OpeningTime other)
 
final boolean equals (final Object o)
 
final int hashCode ()
 
final void setStartTime (final double start_time)
 
final void setEndTime (final double end_time)
 
final double getStartTime ()
 
final double getEndTime ()
 
final String toString ()
 

Static Public Member Functions

static OpeningTime createFromOptionalTimes (OptionalTime start, OptionalTime end)
 

Private Member Functions

final void validateTimes ()
 

Private Attributes

double startTime
 
double endTime
 

Detailed Description

Definition at line 28 of file OpeningTimeImpl.java.

Constructor & Destructor Documentation

◆ OpeningTimeImpl()

org.matsim.facilities.OpeningTimeImpl.OpeningTimeImpl ( final double  startTime,
final double  endTime 
)

Member Function Documentation

◆ createFromOptionalTimes()

static OpeningTime org.matsim.facilities.OpeningTimeImpl.createFromOptionalTimes ( OptionalTime  start,
OptionalTime  end 
)
static

Definition at line 29 of file OpeningTimeImpl.java.

References org.matsim.facilities.OpeningTimeImpl.OpeningTimeImpl(), and org.matsim.core.utils.misc.OptionalTime.orElse().

Referenced by org.matsim.facilities.FacilitiesFromPopulation.assignOpeningTimes().

29  {
30  return new OpeningTimeImpl(start.orElse(Double.NEGATIVE_INFINITY), end.orElse(Double.POSITIVE_INFINITY));
31  }
OpeningTimeImpl(final double startTime, final double endTime)
Here is the call graph for this function:

◆ compareTo()

int org.matsim.facilities.OpeningTimeImpl.compareTo ( OpeningTime  other)

Definition at line 49 of file OpeningTimeImpl.java.

References org.matsim.facilities.OpeningTime.getEndTime(), and org.matsim.facilities.OpeningTime.getStartTime().

49  {
50  // two functionalities in one:
51  // 1. the earlier start_time comes before the other. If they're the same,
52  // the end times decides which comes first
53  // 2. the meaning of the return value. See the ASCII figures for that.
54  if (this.startTime > other.getEndTime()) { // this: |-----|
55  return -6; // other: |--|
56  }
57  else if (this.startTime == other.getEndTime()) { // this: |-----|
58  return -5; // other: |----|
59  }
60  else if (this.startTime > other.getStartTime()) {
61  if (this.endTime > other.getEndTime()) { // this: |-----|
62  return -4; // other: |--------|
63  }
64  else if (this.endTime == other.getEndTime()) { // this: |-----|
65  return -3; // other: |----------|
66  }
67  else { // this: |-----|
68  return -2; // other: |---------------|
69  }
70  }
71  else if (this.startTime == other.getStartTime()) {
72  if (this.endTime > other.getEndTime()) { // this: |-----|
73  return -1; // other: |---|
74  }
75  else if (this.endTime == other.getEndTime()) { // this: |-----|
76  return 0; // other: |-----|
77  }
78  else { // this: |-----|
79  return 3; // other: |----------|
80  }
81  }
82  else if (this.endTime > other.getEndTime()) { // this: |-----|
83  return 2; // other: |-|
84  }
85  else if (this.endTime == other.getEndTime()) { // this: |-----|
86  return 1; // other: |---|
87  }
88  else if (this.endTime > other.getStartTime()) { // this: |-----|
89  return 4; // other: |--------|
90  }
91  else if (this.endTime == other.getStartTime()) { // this: |-----|
92  return 5; // other: |----|
93  }
94  else { // this: |-----|
95  return 6; // other: |--|
96  }
97  }
Here is the call graph for this function:

◆ equals()

final boolean org.matsim.facilities.OpeningTimeImpl.equals ( final Object  o)

Definition at line 104 of file OpeningTimeImpl.java.

References org.matsim.facilities.OpeningTimeImpl.endTime, org.matsim.facilities.OpeningTimeImpl.OpeningTimeImpl(), and org.matsim.facilities.OpeningTimeImpl.startTime.

104  {
105  if (o instanceof OpeningTimeImpl) {
106  OpeningTimeImpl other = (OpeningTimeImpl)o;
107  if ((other.startTime == this.startTime) && (other.endTime == this.endTime)) {
108  return true;
109  }
110  }
111  return false;
112  }
OpeningTimeImpl(final double startTime, final double endTime)
Here is the call graph for this function:

◆ hashCode()

final int org.matsim.facilities.OpeningTimeImpl.hashCode ( )

Definition at line 115 of file OpeningTimeImpl.java.

115  {
116  /* equals() checks day, startTime and endTime, so we should include those into hashCode as well */
117  return (Double.hashCode(this.startTime)
118  + Double.hashCode(this.endTime));
119  }

◆ validateTimes()

final void org.matsim.facilities.OpeningTimeImpl.validateTimes ( )
private

Definition at line 121 of file OpeningTimeImpl.java.

Referenced by org.matsim.facilities.OpeningTimeImpl.OpeningTimeImpl(), org.matsim.facilities.OpeningTimeImpl.setEndTime(), and org.matsim.facilities.OpeningTimeImpl.setStartTime().

121  {
122  Preconditions.checkState(startTime != Double.POSITIVE_INFINITY);
123  Preconditions.checkState(endTime != Double.NEGATIVE_INFINITY);
124  Preconditions.checkState(this.startTime < this.endTime,
125  "[startTime=%s] >= [endTime=%s] not allowed]", this.startTime, this.endTime);
126  }

◆ setStartTime()

final void org.matsim.facilities.OpeningTimeImpl.setStartTime ( final double  start_time)

Implements org.matsim.facilities.OpeningTime.

Definition at line 133 of file OpeningTimeImpl.java.

References org.matsim.facilities.OpeningTimeImpl.validateTimes().

133  {
134  this.startTime = start_time;
135  this.validateTimes();
136  }
Here is the call graph for this function:

◆ setEndTime()

final void org.matsim.facilities.OpeningTimeImpl.setEndTime ( final double  end_time)

Implements org.matsim.facilities.OpeningTime.

Definition at line 139 of file OpeningTimeImpl.java.

References org.matsim.facilities.OpeningTimeImpl.validateTimes().

139  {
140  this.endTime = end_time;
141  this.validateTimes();
142  }
Here is the call graph for this function:

◆ getStartTime()

final double org.matsim.facilities.OpeningTimeImpl.getStartTime ( )
Returns
start time; Double.NEGATIVE_INFINITY if open start

Implements org.matsim.facilities.OpeningTime.

Definition at line 149 of file OpeningTimeImpl.java.

References org.matsim.facilities.OpeningTimeImpl.startTime.

149  {
150  return this.startTime;
151  }

◆ getEndTime()

final double org.matsim.facilities.OpeningTimeImpl.getEndTime ( )
Returns
end time; Double.POSITIVE_INFINITY if open end

Implements org.matsim.facilities.OpeningTime.

Definition at line 154 of file OpeningTimeImpl.java.

References org.matsim.facilities.OpeningTimeImpl.endTime.

154  {
155  return this.endTime;
156  }

◆ toString()

final String org.matsim.facilities.OpeningTimeImpl.toString ( )

Definition at line 163 of file OpeningTimeImpl.java.

References org.matsim.core.utils.misc.Time.writeTime().

163  {
164  return "[startTime=" + Time.writeTime(this.startTime) + "]" +
165  "[endTime=" + Time.writeTime(this.endTime) + "]";
166  }
Here is the call graph for this function:

Member Data Documentation

◆ startTime

double org.matsim.facilities.OpeningTimeImpl.startTime
private

◆ endTime

double org.matsim.facilities.OpeningTimeImpl.endTime
private

The documentation for this class was generated from the following file: