From 965311ff4e2e38ed7d74bf1999eb61ceb3200e64 Mon Sep 17 00:00:00 2001 From: Billy Olsen Date: Fri, 4 Jun 2021 20:34:01 -0700 Subject: [PATCH] FlightConfigurableParameterSet Predictable Orders Change to use a LinkedHashMap instead of a HashMap in the FlightConfigurableParameterSet. This ensures that the ordering is consistent with the way the user added the flight configurations. This will also be true for when reading the flight configurations from a file. Additionally, to preserve the ordering, do not sort the FlightConfigurationIds in getIds(). Fixes #845 Signed-off-by: Billy Olsen --- .../FlightConfigurableParameterSet.java | 10 ++---- .../rocketcomponent/ParameterSetTest.java | 35 ++++++++++++++++--- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurableParameterSet.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurableParameterSet.java index cc4ef365b..91dbf693d 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurableParameterSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurableParameterSet.java @@ -1,8 +1,7 @@ package net.sf.openrocket.rocketcomponent; -import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map.Entry; @@ -21,7 +20,7 @@ import net.sf.openrocket.util.Utils; public class FlightConfigurableParameterSet> implements Iterable { //private static final Logger log = LoggerFactory.getLogger(ParameterSet.class); - protected final HashMap map = new HashMap(); + protected final LinkedHashMap map = new LinkedHashMap(); /** * Construct a FlightConfiguration that has no overrides. @@ -155,11 +154,6 @@ public class FlightConfigurableParameterSet refList = new ArrayList(); + refList.add(fcid1); + refList.add(fcid2); + refList.add(fcid3); + refList.add(fcid4); + + assertEquals(refList, testSet.getIds()); + } }