MATSIM
UmlaufImpl.java
Go to the documentation of this file.
1 
2 /* *********************************************************************** *
3  * project: org.matsim.*
4  * UmlaufImpl.java
5  * *
6  * *********************************************************************** *
7  * *
8  * copyright : (C) 2019 by the members listed in the COPYING, *
9  * LICENSE and WARRANTY file. *
10  * email : info at matsim dot org *
11  * *
12  * *********************************************************************** *
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * See also COPYING, LICENSE and WARRANTY file *
19  * *
20  * *********************************************************************** */
21 
22  package org.matsim.pt;
23 
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.List;
27 
28 import org.matsim.api.core.v01.Id;
30 import org.matsim.vehicles.Vehicle;
31 
32 public class UmlaufImpl implements Umlauf {
33 
34  private Id<Umlauf> id;
36 
37  private ArrayList<UmlaufStueckI> umlaufStuecke = new ArrayList<UmlaufStueckI>();
38 
39  public UmlaufImpl(Id<Umlauf> id) {
40  super();
41  this.id = id;
42  }
43 
44  @Override
45  public List<UmlaufStueckI> getUmlaufStuecke() {
46  return umlaufStuecke;
47  }
48 
49  @Override
50  public Id<Umlauf> getId() {
51  return this.id;
52  }
53 
54  @Override
55  public void setVehicleId(final Id<Vehicle> vehicleId) {
56  this.vehicleId = vehicleId;
57  for (UmlaufStueckI umlaufStueck : umlaufStuecke) {
58  if (umlaufStueck.isFahrt()) {
59  umlaufStueck.getDeparture().setVehicleId(vehicleId);
60  }
61  }
62  }
63 
64  @Override
66  return this.vehicleId;
67  }
68 
69  @Override
71  return getLineId(getUmlaufStuecke());
72  }
73 
74  private Id<TransitLine> getLineId(Collection<UmlaufStueckI> umlaufInConstruction) {
75  Id<TransitLine> lineId = null;
76  for (UmlaufStueckI umlaufStueck : umlaufInConstruction) {
77  if (umlaufStueck.isFahrt()) {
78  if (lineId == null) {
79  lineId = umlaufStueck.getLine().getId();
80  }
81  }
82  }
83  return lineId;
84  }
85 
86 }
UmlaufImpl(Id< Umlauf > id)
Definition: UmlaufImpl.java:39
List< UmlaufStueckI > getUmlaufStuecke()
Definition: UmlaufImpl.java:45
ArrayList< UmlaufStueckI > umlaufStuecke
Definition: UmlaufImpl.java:37
Id< TransitLine > getLineId(Collection< UmlaufStueckI > umlaufInConstruction)
Definition: UmlaufImpl.java:74
Id< Vehicle > getVehicleId()
Definition: UmlaufImpl.java:65
Id< TransitLine > getLineId()
Definition: UmlaufImpl.java:70
Id< Vehicle > vehicleId
Definition: UmlaufImpl.java:35
void setVehicleId(final Id< Vehicle > vehicleId)
Definition: UmlaufImpl.java:55
Id< Umlauf > getId()
Definition: UmlaufImpl.java:50