20: Store variables keys without brackets
This commit is contained in:
+14
-2
@@ -237,9 +237,21 @@ public final class AlarmConfigurationParser {
|
|||||||
|
|
||||||
validateConstantName(name);
|
validateConstantName(name);
|
||||||
|
|
||||||
if (constants.putIfAbsent(name, value) != null) {
|
constants.put(parseVariableName(name), value);
|
||||||
throw new IllegalArgumentException("Duplicate constant: " + name);
|
}
|
||||||
|
|
||||||
|
private static String parseVariableName(String variableName) {
|
||||||
|
if (!variableName.startsWith("{{") || !variableName.endsWith("}}")) {
|
||||||
|
throw new IllegalArgumentException("Invalid variable name: " + variableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String parsedVariableName = variableName.substring(2, variableName.length() - 2);
|
||||||
|
|
||||||
|
if (parsedVariableName.isBlank()) {
|
||||||
|
throw new IllegalArgumentException("Variable name cannot be blank: " + variableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedVariableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String replaceConstants(
|
private static String replaceConstants(
|
||||||
|
|||||||
Reference in New Issue
Block a user