Java Generics and Annotations: Type-Safe

annotations, generics, java

Solution

Unfortunately, there is no inheritance in annotations, so it's not possible.

Have a look at the answers to the similar question here:

Why is not possible to extend annotations in Java?

Problem

I know that I can do something like: ``` public class AbstractDao<T extends Bean> { } ``` In this case, Bean is an class or interface. I was wondering if is there a way to do this with annotations, like: ``` public class AbstractDao<T extends javax.persistence.Entity> { } ``` Is something like this possible? Thanks in advance!

Original source

Related problems