The Bytecode Club - Reverse Engineering Forum
StringVars - Pure Java zero dependency solution to create recursive String variables - Printable Version

+- The Bytecode Club - Reverse Engineering Forum (https://the.bytecode.club)
+-- Forum: Software (https://the.bytecode.club/forumdisplay.php?fid=19)
+--- Forum: Java Projects / Libraries (https://the.bytecode.club/forumdisplay.php?fid=136)
+--- Thread: StringVars - Pure Java zero dependency solution to create recursive String variables (/showthread.php?tid=46009)



StringVars - Pure Java zero dependency solution to create recursive String variables - Konloch - 02-19-2023

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"));