1

How i can add @Override annotation to my method using codeModel?

JMethod update = classe.method(JMod.PUBLIC, void.class,"update");
update.annotate(?); 

i didn't find the @Override Class.

Smern
  • 18,746
  • 21
  • 72
  • 90
user2602584
  • 737
  • 2
  • 7
  • 25
  • I have no idea what you want to do, but `@Override` should be defined in `java.lang.Override` – micha Aug 05 '13 at 14:20

1 Answers1

5

This is how I annotate override annotation on an overridden method using code model.

JMethod update = classe.method(JMod.PUBLIC, void.class,"update");
update .annotate(jCodeModel.ref(Override.class));

PS: : a late reply, may help other who find the same problem.

Naveed S
  • 5,106
  • 4
  • 34
  • 52
Dipak
  • 6,532
  • 8
  • 63
  • 87