Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can OWNER create new instances? #132

Open
vaspoz opened this issue Jul 22, 2015 · 1 comment
Open

Can OWNER create new instances? #132

vaspoz opened this issue Jul 22, 2015 · 1 comment

Comments

@vaspoz
Copy link

vaspoz commented Jul 22, 2015

HI

I wonder, if I could create new object instances from my properties in ".xml" file.
Suppose I have a class Person with few fields:

class Person {
    String name;
    Integer age;

    public Person(String name, Integer age) {
    //omitted
    }
    //getters and setters
}

And Configuration.xml:

<properties>
    <person>
        <name>Vas</name>
        <age>22</age>
    </person>
</properties

And interface:

interface Configuration extends Config {
    @Key("properties.person")
    Person samplePerson();
}

So how can I create some instance like that:

class TestDrive {
    public static void main(String[] args) {
        Configuration config = ConfigFactory.create(Configuration.class);

        Person Andry = config.samplePerson();
        System.out.println(Andry.getName());    // Vas
        System.out.println(Andry.getAge);         // 22
    }
}
@lviggiano
Copy link
Collaborator

Hi @vaspoz

This would be nice, but at the moment it is not supported. It sounds similar to #45 and #129.

At the moment I don't think this can be done with existing features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants