only:extracting methods

This commit is contained in:
Andrey 2024-02-14 15:55:32 -05:00
parent 9f6bce544d
commit 41df2c32d5
1 changed files with 13 additions and 4 deletions

View File

@ -170,10 +170,7 @@ public class EnumIniField extends IniField {
public static EnumKeyValueMap valueOf(String rawText, IniFileModel iniFileModel) {
Map<Integer, String> keyValues = new TreeMap<>();
int interestingIndex = EnumIniField.ordinalIndexOf(rawText, ",", 4);
// yes that could have been done with a regex as well
String interestingPart = rawText.substring(interestingIndex + /*skipping comma*/1).trim();
boolean isKeyValueSyntax = IS_KEY_VALUE_SYNTAX.matcher(interestingPart).matches();
boolean isKeyValueSyntax = isKeyValueSyntax(rawText);
int offset = 5;
String[] tokens = IniFileReader.splitTokens(rawText);
@ -201,6 +198,11 @@ public class EnumIniField extends IniField {
return new EnumKeyValueMap(keyValues);
}
private static boolean isKeyValueSyntax(String rawText) {
String interestingPart = getEnumValuesSection(rawText);
return IS_KEY_VALUE_SYNTAX.matcher(interestingPart).matches();
}
public int size() {
return keyValues.size();
}
@ -217,4 +219,11 @@ public class EnumIniField extends IniField {
throw new IllegalArgumentException("Nothing for " + value);
}
}
@NotNull
private static String getEnumValuesSection(String rawText) {
int interestingIndex = EnumIniField.ordinalIndexOf(rawText, ",", 4);
// yes that could have been done with a regex as well
return rawText.substring(interestingIndex + /*skipping comma*/1).trim();
}
}