MATSIM
AgentSelector.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * Identifier.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2008 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.replanning.identifiers.interfaces;
22 
23 import java.util.Collections;
24 import java.util.LinkedHashSet;
25 import java.util.Set;
26 
27 import org.matsim.api.core.v01.Id;
30 
39 public abstract class AgentSelector {
40 
42  private final Set<AgentFilter> agentFilters = new LinkedHashSet<AgentFilter>();
43 
44  public abstract Set<MobsimAgent> getAgentsToReplan(double time);
45 
46  public final void addAgentFilter(AgentFilter agentFilter) {
47  this.agentFilters.add(agentFilter);
48  }
49 
50  public final boolean removeAgentFilter(AgentFilter agentFilter) {
51  return this.agentFilters.remove(agentFilter);
52  }
53 
54  public final Set<AgentFilter> getAgentFilters() {
55  return Collections.unmodifiableSet(agentFilters);
56  }
57 
58  public final void applyFilters(Set<Id<Person>> set, double time) {
59  for (AgentFilter agentFilter : agentFilters) agentFilter.applyAgentFilter(set, time);
60  }
61 
62  public final boolean applyFilters(Id<Person> id, double time) {
63  for (AgentFilter agentFilter : agentFilters) {
64  if(!agentFilter.applyAgentFilter(id, time)) return false;
65  }
66  return true;
67  }
68 
69  public final void setAgentSelectorFactory(AgentSelectorFactory factory) {
70  this.identifierFactory = factory;
71  }
72 
74  return identifierFactory;
75  }
76 }
abstract Set< MobsimAgent > getAgentsToReplan(double time)
final void setAgentSelectorFactory(AgentSelectorFactory factory)
final boolean applyFilters(Id< Person > id, double time)
final void applyFilters(Set< Id< Person >> set, double time)