I hope I have chosen a title as clear as possible. I have classes annotated with a custom annotation
@MyAnnotation
public class MyClass1 {
//...
}
@MyAnnotation
public class MyClass2 {
//...
}
I have another class that I want to enrich with two methods with the same name: one method that takes only the annotated class as parameters, and the other method that takes other classes as parameters
public class MyOtherClass {
public void myMethod(Object obj) {
//.....
}
public void myMethod (@MyAnnotation Object obj) {
// this method is applied for only classes annotated with @MyAnnotation
}
}
I know that public void myMethod (@MyAnnotation Object obj) is a wrong way we can not pass annotation as parameter. But I want to find the proper way to handle this need.