I'm trying to force class SomeImpl to declare an annotation @SomeAnnotation if it is implementing interface SomeInterface. Solution can modify SomeInterface declaration.
public interface SomeInterface {}
public class SomeImpl implements SomeInterface -> compilation error
@SomeAnnotation
public class SomeInterfaceImpl implements SomeInterface -> compilation ok
Use case: I'm using objects implementing SomeInterface in a method (not written by me, it's an external library) that always read the annotation @SomeAnnotation and it can not be empty or default.
Thanks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.