mercredi 15 juin 2016

Can I inject a annotation into a pojo

Lets say I have a POJO that looks like this.

public class SomeDataClass {

    @SomeProperty1
    String myField1;

    @SomeProperty1
    String myField2;

    ...

    getters()... 
    setters()... // you know the drill

}

I want to be able to synthetically inject an annotation to an instantiated object. The new POJO, if I were to inspect it using reflection, would actually look like this:

public class SomeDataClass {

    @SomeProperty1
    String myField1;

    @SomeProperty1
--> @SomeProperty2 <--- the logic flow would change depending on whether this annotation is present
    String myField2;

    ...

    getters()... 
    setters()... // you know the drill

}

Is this possible? How could I accomplish something like this?





Aucun commentaire:

Enregistrer un commentaire