Giter VIP home page Giter VIP logo

Comments (5)

Exlll avatar Exlll commented on June 18, 2024

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.

alexdev03 avatar alexdev03 commented on June 18, 2024

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.

Exlll avatar Exlll commented on June 18, 2024

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.

alexdev03 avatar alexdev03 commented on June 18, 2024

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.

Exlll avatar Exlll commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.