MATSIM
TripInfoRequestWithActivities.java
Go to the documentation of this file.
1 
2 /*
3  * *********************************************************************** *
4  * project: org.matsim.*
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2019 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** *
20  */
21 
22 package org.matsim.core.mobsim.qsim;
23 
24 import org.matsim.api.core.v01.Scenario;
30 
31 class TripInfoRequestWithActivities implements TripInfo.Request{
32  // this is a pure data class and so one could decide the not have it behind an interface. However, having it behind the interface means that only
33  // hte getters are public, which leaves us more room to refactor. kai, jan'20
34 
35  private final Facility fromFacility;
36  private final Facility toFacility;
37  private final double time;
38  private final TimeInterpretation timeInterpretation;
39  private final Route route;
40 // private final Activity fromActivity;
41 // private final Activity toActivity;
42 
43  private TripInfoRequestWithActivities( Scenario scenario, Activity fromActivity, Activity toActivity, double time,
44  TimeInterpretation timeInterpretation, Route route ) {
45  this.route = route;
46 // this.fromActivity = fromActivity;
47 // this.toActivity = toActivity;
48  this.fromFacility = FacilitiesUtils.toFacility(fromActivity, scenario.getActivityFacilities());
49  this.toFacility = FacilitiesUtils.toFacility(toActivity, scenario.getActivityFacilities());
50  this.time = time;
51  this.timeInterpretation = timeInterpretation;
52  }
53 
54  @Override
55  public Facility getFromFacility() {
56  return fromFacility;
57  }
58 
59  @Override
60  public Facility getToFacility() {
61  return toFacility;
62  }
63 
64  @Override
65  public double getTime() {
66  return time;
67  }
68 
69  @Override
70  public TimeInterpretation getTimeInterpretation() {
71  return timeInterpretation;
72  }
73 
74  @Override
75  public Route getPlannedRoute(){
76  return route;
77  }
78 
79 // Activity getFromActivity() {
80 // return fromActivity;
81 // }
82 //
83 // Activity getToActivity() {
84 // return toActivity;
85 // }
86  // these were used in the code to actually change the activity end time. There is, however, no guarantee that these are still the behavioral objects
87  // . kai, jan'20
88 
89  static class Builder {
90  private final Scenario scenario;
91  private Route route;
92  // this is deliberately a builder and not a constructor so that we can add arguments later without having to add constructors with longer and longer
93  // argument lists. kai, mar'19
94 
95  Builder(Scenario scenario) {
96  this.scenario = scenario;
97  }
98 
99  private double time;
100  private TimeInterpretation timeInterpretation = TimeInterpretation.departure;
101  private Activity fromActivity;
102  private Activity toActivity;
103 
104  Builder setFromActivity(Activity fromActivity) {
105  this.fromActivity = fromActivity;
106  return this;
107  }
108 
109  Builder setToActivity(Activity toActivity) {
110  this.toActivity = toActivity;
111  return this;
112  }
113 
114  Builder setTime(double time) {
115  this.time = time;
116  return this;
117  }
118 
119  Builder setTimeInterpretation(TimeInterpretation timeInterpretation) {
120  this.timeInterpretation = timeInterpretation;
121  return this;
122  }
123 
124  Builder setPlannedRoute( Route route ) {
125  this.route = route ;
126  return this ;
127  }
128 
129  TripInfo.Request createRequest() {
130  return new TripInfoRequestWithActivities(scenario, fromActivity, toActivity, time, timeInterpretation, route);
131  }
132  }
133 }