From 03a43ee29c039fbac7aed2fb5797c8f1272e8ff8 Mon Sep 17 00:00:00 2001 From: Kai Martins-Turner Date: Mon, 25 Mar 2024 15:39:39 +0100 Subject: [PATCH] Rename UNDEFINED_Type to UNDEFINED_PLAN_TYPE (is ok, because was private before) and move it to BasicPlan. --- .../org/matsim/api/core/v01/population/BasicPlan.java | 10 +++++----- .../selectors/GenericWorstPlanForRemovalSelector.java | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/matsim/src/main/java/org/matsim/api/core/v01/population/BasicPlan.java b/matsim/src/main/java/org/matsim/api/core/v01/population/BasicPlan.java index c8263d2264a..5bcf541d5a3 100644 --- a/matsim/src/main/java/org/matsim/api/core/v01/population/BasicPlan.java +++ b/matsim/src/main/java/org/matsim/api/core/v01/population/BasicPlan.java @@ -21,11 +21,11 @@ package org.matsim.api.core.v01.population; -import org.matsim.core.replanning.selectors.GenericWorstPlanForRemovalSelector; - public interface BasicPlan { - void setScore( Double score ); + String UNDEFINED_PLAN_TYPE = "undefined"; + + void setScore(Double score ); Double getScore(); @@ -33,7 +33,7 @@ public interface BasicPlan { * Plan type, which may be used to ensure there is at least one plan of a certain type. */ default String getType() { - return GenericWorstPlanForRemovalSelector.UNDEFINED_TYPE; + return UNDEFINED_PLAN_TYPE; } - + } diff --git a/matsim/src/main/java/org/matsim/core/replanning/selectors/GenericWorstPlanForRemovalSelector.java b/matsim/src/main/java/org/matsim/core/replanning/selectors/GenericWorstPlanForRemovalSelector.java index 49d4971caa1..61e2df24a2e 100644 --- a/matsim/src/main/java/org/matsim/core/replanning/selectors/GenericWorstPlanForRemovalSelector.java +++ b/matsim/src/main/java/org/matsim/core/replanning/selectors/GenericWorstPlanForRemovalSelector.java @@ -28,6 +28,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import static org.matsim.api.core.v01.population.BasicPlan.UNDEFINED_PLAN_TYPE; + /** *

Selects the worst plan of a person (most likely for removal), but respects * the set plan types in a way the no plan is selected that is the last one of @@ -41,8 +43,6 @@ */ public class GenericWorstPlanForRemovalSelector implements PlanSelector { - public static final String UNDEFINED_TYPE = "undefined"; - @Override public T selectPlan(HasPlansAndId person) { @@ -53,7 +53,7 @@ public T selectPlan(HasPlansAndId person) { for (T plan : person.getPlans()) { String type = plan.getType(); if ( type==null ) { - type = UNDEFINED_TYPE ; + type = UNDEFINED_PLAN_TYPE; } typeCounts.merge( type, 1, ( a, b ) -> a + b ); } @@ -64,7 +64,7 @@ public T selectPlan(HasPlansAndId person) { String type = plan.getType(); if ( type==null ) { - type = UNDEFINED_TYPE; + type = UNDEFINED_PLAN_TYPE; } if ( typeCounts.get( type ) > 1) { // (if we have more than one plan of the same type:)