The Bytecode Club

Full Version: StringVars - Pure Java zero dependency solution to create recursive String variables
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
About: StringVars is a zero dependency pure Java solution to create recursive String variables, such as $var$ or %var%.
License: Public Domain
Source: https://konloch.com/StringVars/
Download Jar: https://konloch.com/StringVars/releases/
Add as maven dependency:
Code:
<dependency>
  <groupId>com.konloch</groupId>
  <artifactId>StringVars</artifactId>
  <version>1.0.0</version>
</dependency>

Implementation Example
Click here for the StringHolderExample class
Code:
StringHolderExample example = new StringHolderExample()
{
    @Override
    public String getString(String key)
    {
        return StringVars.getVariableValue('$', ()-> getMap().get(key),(vkey)-> getMap().get(vkey));
    }
};
        
example.getMap().put("example", "Example: $var$");
example.getMap().put("var", "This is a great example of how it functions!");

System.out.println("Results: " + example.getString("example"));