vendredi 3 juillet 2020

Override value of field in type annotation, when this annotation is part of other annotation in java

Lets assume I have following annotation types:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TypeA {   
    TypeB[] arrayOfTypeB();
}

public @interface TypeB {
    String firstField();
    String secondField();
}

And a class that uses these annotation types:

@TypeA(arrayOfTypeB = {
        @TypeB(
                firstField = "first field",
                secondField = "second field"),
})
public class ClassUsingTheseTypes{
}

How to change secondFIeld value using reflection in Java?





Aucun commentaire:

Enregistrer un commentaire