I need to mark some classes as Invokable – just to tell I can invoke methods of the class using reflection. But I don’t like the idea of having an empty interface just for this purpose. Can this be done with annotations and still preserve behaviour on the example below? (I have never created my own annotations, so I’m not familiar with them in depth)
Example
class ClassOne implements Invokable {
}
class ClassTwo implements Invokable {
}
void someMethod(Invokable inv) {
}
Because of
someMethod, you can’t use annotations. Perhaps later you’ll find thatInvokablemay need useful methods anyway.Also, be sure to check out already existing interfaces like
Callable,Futureetc. before you re-invent the wheel.