diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/EnumPair.java b/java_tools/configuration_definition/src/main/java/com/rusefi/EnumPair.java index 058f1fafa5..32b7437451 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/EnumPair.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/EnumPair.java @@ -1,19 +1,19 @@ package com.rusefi; public class EnumPair { - private final String shorterForm; - private final String simpleForm; + private final String keyValueForm; + private final String arrayForm; - public EnumPair(String shorterForm, String simpleForm) { - this.shorterForm = shorterForm; - this.simpleForm = simpleForm; + public EnumPair(String keyValueForm, String arrayForm) { + this.keyValueForm = keyValueForm; + this.arrayForm = arrayForm; } - public String getShorterForm() { - return shorterForm; + public String getKeyValueForm() { + return keyValueForm; } - public String getSimpleForm() { - return simpleForm; + public String getArrayForm() { + return arrayForm; } } diff --git a/java_tools/configuration_definition/src/main/java/com/rusefi/pinout/PinoutLogic.java b/java_tools/configuration_definition/src/main/java/com/rusefi/pinout/PinoutLogic.java index 3c4643a5f1..a47ae057f5 100644 --- a/java_tools/configuration_definition/src/main/java/com/rusefi/pinout/PinoutLogic.java +++ b/java_tools/configuration_definition/src/main/java/com/rusefi/pinout/PinoutLogic.java @@ -81,22 +81,23 @@ public class PinoutLogic { String nothingName = namePinType.getNothingName(); EnumsReader.EnumState enumList = enumsReader.getEnums().get(pinType); EnumPair pair = enumToOptionsList(nothingName, enumList, kv.getValue()); - if (pair.getSimpleForm().length() > 0) { + if (pair.getArrayForm().length() > 0) { // we seem to be here if specific pin category like switch_inputs has no pins - parseState.addDefinition(registry, outputEnumName + ENUM_SUFFIX, pair.getShorterForm(), Definition.OverwritePolicy.IgnoreNew); + parseState.addDefinition(registry, outputEnumName + ENUM_SUFFIX, pair.getKeyValueForm(), Definition.OverwritePolicy.IgnoreNew); } - parseState.addDefinition(registry, outputEnumName + FULL_JAVA_ENUM, pair.getSimpleForm(), Definition.OverwritePolicy.IgnoreNew); + parseState.addDefinition(registry, outputEnumName + FULL_JAVA_ENUM, pair.getArrayForm(), Definition.OverwritePolicy.IgnoreNew); } } @NotNull public static EnumPair enumToOptionsList(String nothingName, EnumsReader.EnumState enumList, ArrayList values) { - StringBuilder simpleForm = new StringBuilder(); + // "value0", "value1", "value2" format + StringBuilder arrayFormat = new StringBuilder(); Map pinMap = new HashMap<>(); for (int i = 0; i < values.size(); i++) { - appendCommaIfNeeded(simpleForm); + appendCommaIfNeeded(arrayFormat); String key = enumList.findByValue(i); String value = values.get(i); @@ -106,16 +107,17 @@ public class PinoutLogic { pinMap.put(i, value); } if (key.equals(nothingName)) { - simpleForm.append(QUOTED_NONE); + arrayFormat.append(QUOTED_NONE); } else if (value == null) { - simpleForm.append(QUOTED_INVALID); + arrayFormat.append(QUOTED_INVALID); } else { String quotedValue = quote(value); - simpleForm.append(quotedValue); + arrayFormat.append(quotedValue); } } + // 2="Value2",5="value5" format String keyValueForm = VariableRegistry.getHumanSortedTsKeyValueString(pinMap); - return new EnumPair(keyValueForm, simpleForm.toString()); + return new EnumPair(keyValueForm, arrayFormat.toString()); } private static void appendCommaIfNeeded(StringBuilder sb) { diff --git a/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicTest.java b/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicTest.java index 9e8654e86e..2426314b85 100644 --- a/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicTest.java +++ b/java_tools/configuration_definition/src/test/java/com/rusefi/pinout/PinoutLogicTest.java @@ -1,7 +1,6 @@ package com.rusefi.pinout; import com.rusefi.EnumsReader; -import com.rusefi.pinout.PinoutLogic; import com.rusefi.enum_reader.Value; import org.junit.Test; @@ -22,14 +21,14 @@ public class PinoutLogicTest { { ArrayList list = new ArrayList<>(Arrays.asList("1", "NO", "10")); - String result = PinoutLogic.enumToOptionsList("NO", enumState, list).getShorterForm(); + String result = PinoutLogic.enumToOptionsList("NO", enumState, list).getKeyValueForm(); assertEquals("0=\"NONE\",2=\"10\",1=\"NO\"", result); } { ArrayList list = new ArrayList<>(Arrays.asList("1", "NO", null, null, null, null, null, "10")); - String result = PinoutLogic.enumToOptionsList("NO", enumState, list).getShorterForm(); + String result = PinoutLogic.enumToOptionsList("NO", enumState, list).getKeyValueForm(); assertEquals("0=\"NONE\",7=\"10\",1=\"NO\"", result); } }