Comments (10)
Before I forget - I'm using Kotlin 1.2.30 and Java 8 / 1.8 if that's helpful or important for whatever reason.
from cfg4k.
Taking a look. I'm not sure if inside an enum the DefaultImpls
is different or something. Actually that's one of the things that I didn't think of, an enum with methods and default.
from cfg4k.
Thanks for taking a look! Yeah that was one thought I had, but what was weird was that it seemed to be failing on this issue in the the base Config
class regardless of the enum's involvement as I was testing different things out.
from cfg4k.
Ohhh, I think I know what's happening.
An enum class is a real class (not an interface) and it will not have DefaultImpl
but real implementations. Let me try it and maybe there's a workaround defining an interface for the Enum.
from cfg4k.
Yes, that is exactly what is happening (I'll try to fix it to work with classes anyways though)
enum class TestEnum : Interf {
TEST, TEST1, TEST2
}
interface Interf {
val name: String
val slug: String get() = name.toLowerCase()
}
If you use it like that you won't have any problems
it("binding test") {
val testBinder = provider.bind<BindedEnum>("")
testBinder.thisWillBeEnum().should.be.equal(TestEnum.TEST)
testBinder.thisWillBeEnum().slug.should.be.equal(TestEnum.TEST.name.toLowerCase())
}
from cfg4k.
I tried stripping out the enum entirely and actually get the same thing:
com.jdiazcano.cfg4k.utils.SettingNotFound: Setting server not found
at com.jdiazcano.cfg4k.binders.BindingInvocationHandler.invoke(BindingInvocationHandler.kt:65)
at com.sun.proxy.$Proxy0.getServer(Unknown Source)
at AppServer.run(AppServer.kt:33)
at AppServer.main(AppServer.kt:16)
Note for context, that this error setting server not found
is a red herring as it is actually swallowing the ClassNotFoundException
I mentioned in the original post
Any chance there might be two separate issues going on here? One the enum but the other the cause of the original Exception?
from cfg4k.
Current code is the same for the server portion, but this is all there is now in the Config.kt file:
interface Config {
val database: DatabaseConfig
val server: ServerConfig
}
interface DatabaseConfig {
val url: String
val username: String
val password: String
}
interface ServerConfig {
val port: Int
val host: String
val environment: String
}
from cfg4k.
Could you paste also the properties
file changing all the strings for something else? It might be related to naming then
And if you want I'm available in kotlin slack.
from cfg4k.
So the real issue is that Environment
and System
loaders right now do not support binding due to the way that it is designed right now.
They still can be used with a normal get<String>("server.host")
from cfg4k.
Now both extends DefaultConfigLoader so merges and binding are supported.
The only caveat is that if you try to add value to an already set object a warning will be emitted.
from cfg4k.
Related Issues (20)
- FileChangeReloadStrategy watcher uses incorrect test HOT 3
- ByteBuddyBinder creates a new class on every method invocation HOT 6
- FileChangeReloadStrategy thread dies on Exception: no error handler HOT 3
- ConfigSources that wraps authorized URL calls HOT 1
- Vault Config HOT 3
- import com.jdiazcano.cfg4k.json.JsonConfigLoader HOT 2
- Resolving hocon variables does not work for quoted strings HOT 1
- Hocon config mapper does not handle nulls HOT 1
- Spurious WARN at startup on Oracle JDK HOT 1
- HOCON substitutions, override via file and via environment/system prop HOT 2
- Using of EnvironmentConfigLoader based provider requires all the intermediate 'nodes' to be declared HOT 14
- Remake tests HOT 2
- Map of Strings? HOT 4
- Reloading when merging
- [BUG] Unexpected crash in DefaultConfigLoader.get with IllegalArgumentException: Trying to get a key from a primitive HOT 5
- Multiplatform HOT 2
- [BUG] FileChangeReloadStrategy doesn't deal properly with symlink changes HOT 1
- BinTray deprecated, move to Maven Central HOT 2
- Library versions with known CVEs HOT 2
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 cfg4k.