21 package org.matsim.core.population;
23 import java.util.ArrayList;
24 import java.util.List;
27 import org.apache.logging.log4j.LogManager;
28 import org.apache.logging.log4j.Logger;
41 final class PlanImpl
implements Plan {
43 private Id<Plan>
id= null;
45 private ArrayList<PlanElement> actsLegs =
new ArrayList<>();
47 private Double score = null;
48 private Person person = null;
50 private String type = null;
52 private final static Logger log = LogManager.getLogger(Plan.class);
54 private Customizable customizableDelegate;
56 private final Attributes attributes =
new AttributesImpl();
59 public final Attributes getAttributes() {
60 return this.attributes;
99 public final Person getPerson() {
104 public void setPerson(
final Person person) {
105 this.person = person;
109 public final Double getScore() {
114 public void setScore(
final Double score) {
119 public String getType() {
124 public void setType(
final String type) {
129 public Id<Plan> getId() {
133 if(this.getAttributes().getAttribute(PlanInheritanceModule.PLAN_ID)!=null)
134 return Id.create(this.getAttributes().getAttribute(PlanInheritanceModule.PLAN_ID).toString(),Plan.class);
141 public void setPlanId(Id<Plan> planId) {
142 this.getAttributes().putAttribute(PlanInheritanceModule.PLAN_ID, planId.toString());
147 public int getIterationCreated() {
148 return (
int) this.getAttributes().getAttribute(PlanInheritanceModule.ITERATION_CREATED);
152 public void setIterationCreated(
int iteration) {
153 this.getAttributes().putAttribute(PlanInheritanceModule.ITERATION_CREATED, iteration);
157 public String getPlanMutator() {
158 return (String) this.getAttributes().getAttribute(PlanInheritanceModule.PLAN_MUTATOR);
162 public void setPlanMutator(String planMutator) {
163 this.getAttributes().putAttribute(PlanInheritanceModule.PLAN_MUTATOR, planMutator);
167 public final List<PlanElement> getPlanElements() {
168 return this.actsLegs;
172 public final void addLeg(
final Leg leg) {
173 this.actsLegs.add(leg);
177 public final void addActivity(
final Activity act) {
178 this.actsLegs.add(act);
182 public final String toString() {
184 String scoreString =
"undefined";
185 if (this.getScore() != null) {
186 scoreString = this.getScore().toString();
188 String personIdString =
"undefined" ;
189 if ( this.getPerson() != null ) {
190 personIdString = this.getPerson().getId().toString() ;
193 return "[score=" + scoreString +
"]" +
195 "[nof_acts_legs=" + getPlanElements().size() +
"]" +
196 "[type=" + this.type +
"]" +
197 "[personId=" + personIdString +
"]" ;
201 public final Map<String, Object> getCustomAttributes() {
202 if (this.customizableDelegate == null) {
203 this.customizableDelegate = CustomizableUtils.createCustomizable();
205 return this.customizableDelegate.getCustomAttributes();