szidijani
szidijani

Reputation: 1014

How to define a java Annotation, that gets to an overridden method automatically?

I'd like to create a custom Java Annotation, which can be applied to a method in an interface. What I'd like is, that when I override the method, that belongs to that interface, an annotation gets above the overridden method automatically.

This is my very simple interface, used for callback:

public interface ChangeToArcherNotifier {
    public void ChangeToArcher();
}

And when I implement it, I want that method to be marked with an annotation, like this:

@Callback
@Override
public void ChangeToArcher() {

}

Upvotes: 0

Views: 50

Answers (1)

peter.petrov
peter.petrov

Reputation: 39477

You cannot do this. If you program in Notepad e.g., who do you expect to paste the annotation name above the method in the source file of the class implementing the interface? This is up to your IDE (if the IDE supports such a feature).

Upvotes: 1

Related Questions