MATSIM
SingleModeNetworksCache.java
Go to the documentation of this file.
1 
2 /* *********************************************************************** *
3  * project: org.matsim.*
4  * SingleModeNetworksCache.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.core.router;
23 
24 import java.util.HashSet;
25 import java.util.Map;
26 import java.util.Set;
27 import java.util.concurrent.ConcurrentHashMap;
28 
33 
34 import com.google.inject.Inject;
35 
37 
38  private final Map<String, Network> singleModeNetworksCache = new ConcurrentHashMap<>();
39  private final Network fullNetwork;
41 
42  @Inject
43  public SingleModeNetworksCache(Network fullNetwork, NetworkConfigGroup networkConfigGroup) {
44  this.fullNetwork = fullNetwork;
45  this.networkConfigGroup = networkConfigGroup;
46  }
47 
48  public Map<String, Network> getSingleModeNetworksCache() {
50  }
51 
52  public Network getOrCreateSingleModeNetwork(final String mode) {
53  return getSingleModeNetworksCache().computeIfAbsent(mode, this::filterNetwork);
54  }
55 
56  private Network filterNetwork(final String mode) {
58  Set<String> modes = new HashSet<>();
59  modes.add(mode);
60 
61  final Network filteredNetwork = NetworkUtils.createNetwork(networkConfigGroup);
62  filter.filter(filteredNetwork, modes);
63 
64  return filteredNetwork;
65  }
66 }
void filter(final Network subNetwork, final Set< String > extractModes)
SingleModeNetworksCache(Network fullNetwork, NetworkConfigGroup networkConfigGroup)