I have a very dynamic settings config of sorts. It can reference other config values within strings, and even other random non-static variables.
Example of a config value using this: “abcdefg [config.othervalue]”
If config.othervalue was “text”, then this config value would become: “abcdefg text”
However, as I mentioned, some of the “variables” won’t be static. They might reference context that isn’t always accessible.
To insert these config values, I was originally planning to just use str.replaceAll, by just looping all the variables I would need to insert. However, since some stuff isn’t static, I’d have to do this on runtime. Likely every time the config value in question is used. Obviously this is a potential performance leak.
Is there any better way to insert the necessary variables? Some way to check what variables are used and only inserting those?