Вопрос

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

}
Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top