Comments (5)
If you annotate Background
with @Configuration
, do you get the output you want? If yes, that's the intended behavior. In that case, you also don't need to annotate the subclasses with either @Configuration
or @Polymorphic
.
from configlib.
Thanks, it worked. Is it possibile to remove PolymorphicType section?
background: type: integer
Maybe you could check all possible classes and check if there is a match.
from configlib.
You only need @PolymorphicTypes
to define aliases. You don't have to use this annotation but then the Java class name is used.
If you want to use aliases without having to use @PolymorphicTypes
that's not possible because there are several ambiguous cases where it is not clear which class should be selected. The most obvious example: If two sub classes have exactly the same name and structure but reside in different packages, then which of the two should I instantiate?
@Configuration
@Polymorphic
public static class Background {}
// in package com.example.bg1
public static class IntegerBackground extends Background {
private int r, g, b;
}
// in package com.example.bg2
public static class IntegerBackground extends Background {
private int r, g, b;
}
That's the reason that I either need to have the full Java class name or access to the class literal via the annotation.
from configlib.
Why should you use subclasses if you have same parameters? Couldn't you just make an option in @Polymorphic
to enable find class process? If it's enabled and there is a problem you just throw an exception. I just don't like having this section in the config, it could confuse the user.
from configlib.
Well, as I wrote, this is just the most obvious example where there is ambiguity. Also, I'd prefer if we could discuss the details of your feature request in a separate issue (I'm not sure whether I'll be able to implement it anytime soon).
from configlib.
Related Issues (20)
- Add option to ignore fields from serialization HOT 1
- GitHub authentication problem HOT 8
- [Help] Unknown class deserialization HOT 16
- Add support for java 16+ HOT 5
- How does the library handle breaking changes(examples provided)? HOT 2
- [BUG] Unable to Initialize "Configuration class 'ConfigYAML' does not contain any (de-)serializable fields." HOT 2
- Achieve cross-version support by making the library compatible with Java 8 HOT 5
- Shade ConfigLib using Java 8 HOT 2
- Charset string problem HOT 6
- Add better support for updating configurations HOT 2
- Allow loading configs from internal JAR resources via an InputStream HOT 5
- Native support for Adventure API Component HOT 2
- Config value POST load handler support HOT 12
- Not working jitpack.io HOT 4
- Will comments be added in lists/maps etc? HOT 2
- Publish to maven central HOT 3
- Enums as Keys in Maps HOT 2
- Comments are not processed HOT 1
- Server is offline HOT 5
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 configlib.