mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-16 01:19:49 +00:00
Minimum and maximum times occuring in trips, legs and stops.
This commit is contained in:
parent
8c1ba6eabb
commit
96c449ccc8
2 changed files with 70 additions and 0 deletions
|
@ -177,6 +177,22 @@ public final class Stop implements Serializable
|
|||
return predictedDeparturePosition != null;
|
||||
}
|
||||
|
||||
public Date getMinTime()
|
||||
{
|
||||
if (plannedDepartureTime == null || (predictedDepartureTime != null && predictedDepartureTime.before(plannedDepartureTime)))
|
||||
return predictedDepartureTime;
|
||||
else
|
||||
return plannedDepartureTime;
|
||||
}
|
||||
|
||||
public Date getMaxTime()
|
||||
{
|
||||
if (plannedArrivalTime == null || (predictedArrivalTime != null && predictedArrivalTime.after(plannedArrivalTime)))
|
||||
return predictedArrivalTime;
|
||||
else
|
||||
return plannedArrivalTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -110,6 +110,30 @@ public final class Trip implements Serializable
|
|||
return null;
|
||||
}
|
||||
|
||||
/** Minimum time occuring in this trip. */
|
||||
public Date getMinTime()
|
||||
{
|
||||
Date minTime = null;
|
||||
|
||||
for (final Leg leg : legs)
|
||||
if (minTime == null || leg.getMinTime().before(minTime))
|
||||
minTime = leg.getMinTime();
|
||||
|
||||
return minTime;
|
||||
}
|
||||
|
||||
/** Maximum time occuring in this trip. */
|
||||
public Date getMaxTime()
|
||||
{
|
||||
Date maxTime = null;
|
||||
|
||||
for (final Leg leg : legs)
|
||||
if (maxTime == null || leg.getMaxTime().after(maxTime))
|
||||
maxTime = leg.getMaxTime();
|
||||
|
||||
return maxTime;
|
||||
}
|
||||
|
||||
public List<Product> products()
|
||||
{
|
||||
final List<Product> products = new LinkedList<Product>();
|
||||
|
@ -224,6 +248,12 @@ public final class Trip implements Serializable
|
|||
|
||||
/** Coarse arrival time. */
|
||||
public abstract Date getArrivalTime();
|
||||
|
||||
/** Minimum time occuring in this leg. */
|
||||
public abstract Date getMinTime();
|
||||
|
||||
/** Maximum time occuring in this leg. */
|
||||
public abstract Date getMaxTime();
|
||||
}
|
||||
|
||||
public final static class Public extends Leg
|
||||
|
@ -312,6 +342,18 @@ public final class Trip implements Serializable
|
|||
return arrivalStop.isArrivalPositionPredicted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getMinTime()
|
||||
{
|
||||
return departureStop.getMinTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getMaxTime()
|
||||
{
|
||||
return arrivalStop.getMaxTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -375,6 +417,18 @@ public final class Trip implements Serializable
|
|||
return arrivalTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getMinTime()
|
||||
{
|
||||
return departureTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getMaxTime()
|
||||
{
|
||||
return arrivalTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue