Created
July 10, 2014 09:07
-
-
Save 2m/941ed15336d92748cd39 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
import com.typesafe.config.Config; | |
import com.typesafe.config.ConfigFactory; | |
import java.util.Map; | |
import java.util.HashMap; | |
public class ConfigOverrideFromCode { | |
static public void main(String[] args) { | |
String config = "system {\n" + | |
" administrator = ${who-knows}\n" + | |
" developer = ${to-be-assigned-later}\n" + | |
"}"; | |
Map<String, String> values = new HashMap<String, String>(); | |
values.put("who-knows", "jon"); | |
values.put("to-be-assigned-later", "kate"); | |
Config original = ConfigFactory | |
.parseString(config) | |
.resolveWith(ConfigFactory.parseMap(values)); | |
System.out.println(original.getString("system.administrator")); | |
System.out.println(original.getString("system.developer")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment