MATSIM
TransportModeProvider.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * TransportModeProvider.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2013 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 package org.matsim.withinday.trafficmonitoring;
22 
23 import java.util.Map;
24 import java.util.concurrent.ConcurrentHashMap;
25 
26 import org.matsim.api.core.v01.Id;
34 
41 
42  private final Map<Id<Person>, String> transportModes = new ConcurrentHashMap<Id<Person>, String>();
43 
44  public String getTransportMode(Id<Person> agentId) {
45  return this.transportModes.get(agentId);
46  }
47 
48  @Override
49  public void reset(int iteration) {
50  this.transportModes.clear();
51  }
52 
53  @Override
54  public void handleEvent(PersonStuckEvent event) {
55  this.transportModes.remove(event.getPersonId());
56  }
57 
58  @Override
59  public void handleEvent(PersonDepartureEvent event) {
60  this.transportModes.put(event.getPersonId(), event.getLegMode());
61  }
62 
63  @Override
64  public void handleEvent(PersonArrivalEvent event) {
65  this.transportModes.remove(event.getPersonId());
66  }
67 
68 }