I am working on a project built on Java
.
I have a use case where I have multiple templates of strings
that need to be formatted by replacing keywords with their values.
Since the position of parameter and name of the parameter is not always known and will change over time I want to write a function that takes a string and replace keywords (named parameter) with their values using the map.
For e.g.
Hi my name is %name
And if I have map = {"name":"user1"}
Then my function should replace the name with user1.
I tried to find if there is already an existing method or library in java but I couldn't find any.