I want to implement a custom annotation which when used by other classes exposes two methods to them. Something like shown below:
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface BaseEntity{
public String toString(){ return "Hello" ;}
public String toCustomString() { return "my hello";}
}
Now what I want is whenever any class uses the above annotation. It gets these methods exposed to it by default, something like what Lombok does when we use @Getter
@BaseEntity
public class Person{}
Person p = new Person();
p.toCustomString(); // this should work