Created
October 27, 2018 19:41
-
-
Save prashantpandey10/532bfa03ca45f99128fe51b28c890908 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AmpleMarket { | |
public static void main(String[] args) { | |
String mainString = "hi {!first name}"; | |
HashMap<String,String> patternDictonary = new HashMap<>(); | |
patternDictonary.put("first name","prashant"); | |
populateTemplate(mainString, patternDictonary); | |
} | |
private static void populateTemplate(String mainString, HashMap patternDictonary) { | |
for (Object key : patternDictonary.keySet()) { | |
String singleKey = "{!"+key+"}"; | |
if(mainString.contains(singleKey)){ | |
mainString = mainString.replace(singleKey, (CharSequence) patternDictonary.get(key)); | |
} | |
} | |
System.out.println(mainString); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment