Comments (5)
There are some docs on doing something like this here in the Akka docs I think, search for "lift-a-subtree" in http://doc.akka.io/docs/akka/snapshot/general/configuration.html
Those docs talk about config.getConfig("b1").withFallback(config.withOnlyPath("a"))
or something along those lines. I guess the issue is that you want to stick a prefix on b1 (the subtree doesn't start with the root).
So maybe a method like prefix
? config.getConfig("b1").prefix("a.b").withFallback(config.withOnlyPath("a"))
or so? Does that work?
from config.
Possible patch at havocp-multiline-strings...havocp-under-path
Wondering if a better or additional change would be to just add a "setter" method to Config/ConfigObject (equivalent of Map.put but returning a new object instead of mutating). Have to think what it would be called; to be most convenient it should be something(String path, Object anything)
and use ConfigValueFactory.fromAnyRef
to interpret anything
, I'm thinking. So withValue
I'd expect to be withValue(String path, ConfigValue value)
instead. withAnyRef
would be most consistent with existing method names. Just something concise like plus
or add
or something might work too but those really should take a ConfigValue
to be consistent with the overall API of Config/ConfigObject (they are String,ConfigValue mappings). Having the method take ConfigValue
instead of Object
would probably be clearer, but also too verbose to use in the common cases that people would use this.
from config.
Thank you for your quick reply and patch. The patch already makes things much easier.
As for the a put-like interface, probably plus
would be most consistent with Scala's Map
interface and I agree it should take a ConfigValue
, not anything.
Regarding ConfigValueFactory
, syntax-wise it would be cool to do ConfigValueFactory.at("some.path").fromAnyRef
. It would be achievable by having a factory object with "some.path" built-in. I haven't looked at the code to see how easy would that be to implement, tho.
from config.
I added a withValue() also and merged to master. I went with withValue() because we have withoutKey() already (rather than "minus") so withValue() seems to go with it better. Didn't want to have both "minus" and "withoutKey" as synonyms, didn't want to have "plus" and "withoutKey" as opposites that didn't go together. I guess it's good to stick to this "with" convention too.
More convenience API would be possible but I guess just keeping it simple for now. In Scala one might make things a good bit nicer by importing some implicit conversions from various types to ConfigValue, like:
implicit int2configvalue(v: Int): ConfigValue = ConfigValueFactory.fromAnyRef(v)
Then you could just write config.withValue("a.b.", 42)
etc. I believe.
from config.
Sounds very good. Thank you!
from config.
Related Issues (20)
- Is this project active? HOT 4
- Find a StackOverflowError in config
- Find a StackOverflowError in config
- Find a StackOverflowError in config HOT 1
- underscore characters HOT 2
- Problems with com.typesafe/config and maven-dependency-plugin
- introduce method accepting a list of Objects to add a value
- Should this project be explicitly considered as deprecated/not supported? HOT 29
- Community fork? HOT 7
- Resolving Variable Substitutions Between Multiple Config HOT 1
- Something error when use com.typesafe.config API convert conf file to scala bean class
- withFallBack is not adding value if not present
- how to load the config with substitution details HOT 3
- Add info about which signing keys will be used for published artifacts.
- Cannot provide environment variables programmatically
- Rendering partially resolved appended array results in invalid configuration HOT 1
- Inconsistent behavior with Overflow/Underflow and Exceptions
- Regression in environment variable reading behavior HOT 2
- Add a module info HOT 6
- Question about `ConfigFactory.systemProperties()` on windows HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from config.