MATSIM
PopulationFactoryImpl.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * *
4  * *********************************************************************** *
5  * *
6  * copyright : (C) 2008 by the members listed in the COPYING, *
7  * LICENSE and WARRANTY file. *
8  * email : info at matsim dot org *
9  * *
10  * *********************************************************************** *
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * See also COPYING, LICENSE and WARRANTY file *
17  * *
18  * *********************************************************************** */
19 
20 package org.matsim.core.population;
21 
22 import jakarta.inject.Inject;
23 
24 import org.matsim.api.core.v01.Coord;
25 import org.matsim.api.core.v01.Id;
36 
40 /* deliberately package */ class PopulationFactoryImpl implements PopulationFactory {
41 
42  private final RouteFactories routeFactory;
43 
44  @Inject
45  PopulationFactoryImpl(RouteFactories routeFactory) {
46  this.routeFactory = routeFactory;
47  }
48 
49  @Override
50  public Person createPerson(final Id<Person> id) {
51  return new PersonImpl(id) ;
52  }
53 
54  @Override
55  public Plan createPlan(){
56  return new PlanImpl() ;
57  }
58 
59  @Override
60  public Activity createActivityFromCoord(final String actType, final Coord coord) {
61  Activity act = new ActivityImpl(actType) ;
62  act.setCoord(coord);
63  return act ;
64  }
65 
66  @Override
67  public Activity createInteractionActivityFromCoord(final String actType, final Coord coord) {
68  Activity act = new InteractionActivity(actType) ;
69  act.setCoord(coord);
70  return act ;
71  }
72 
73  @Override
74  public Activity createActivityFromLinkId(final String actType, final Id<Link> linkId) {
75  Activity act = new ActivityImpl(actType) ;
76  act.setLinkId(linkId);
77  return act ;
78  }
79 
80  @Override
81  public Activity createInteractionActivityFromLinkId(final String actType, final Id<Link> linkId) {
82  Activity act = new InteractionActivity(actType) ;
83  act.setLinkId(linkId);
84  return act ;
85  }
86 
87  @Override
88  public Activity createActivityFromActivityFacilityId( String actType, Id<ActivityFacility> activityFacilityId ){
89  Activity act = new ActivityImpl( actType ) ;
90  act.setFacilityId( activityFacilityId );
91  return act ;
92  }
93 
94  @Override
95  public Activity createInteractionActivityFromActivityFacilityId( String actType, Id<ActivityFacility> activityFacilityId ){
96  Activity act = new InteractionActivity( actType ) ;
97  act.setFacilityId( activityFacilityId );
98  return act ;
99  }
100 
101  @Override
102  public Leg createLeg(final String legMode) {
103  return new LegImpl(legMode) ;
104  }
105 
106 
113  public void setRouteFactory(final Class<? extends Route> routeType, final RouteFactory factory) {
114  this.routeFactory.setRouteFactory(routeType, factory);
115  }
116 
117  @Override
118  public RouteFactories getRouteFactories() {
119  return this.routeFactory;
120  }
121 
122 }