Java Generics and Annotations: Type-Safe

I know I can do something like:

public class AbstractDao<T extends Bean> {

}

In this case, the Bean is a class or interface.

I was wondering if there is a way to do this using annotations, for example:

public class AbstractDao<T extends javax.persistence.Entity> {

}

Is this possible?

Thanks in advance!

+5
source share
2 answers

Unfortunately, annotations do not have inheritance, so this is not possible.

See answers to a similar question here:

Why can't annotations extend in Java?

+3
source

. Java , / . , .

+3

All Articles