Frage

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() {

}
War es hilfreich?

Lösung

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).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top