Having my custom annotation:
@Inherited
@Target({ElementType.TYPE, ElementType.TYPE_PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface EntityDomain {
}
My objective is declare an interface where the type parameter
must be a type annotated with @EntityDomain
Such as:
@EntityDomain
public class Person implements Serializable {
I did a research in:
I have created
@FunctionalInterface
public interface EntityRetrievalForPersistence<@EntityDomain T> {
T getEntity();
}
But something is missing because the following compiles:
public enum StringTest implements EntityRetrievalForPersistence<String>{
A("A"),
B("B");
private String x;
private StringTest(String x) {
this.x = x;
}
@Override
public String getEntity() {
// TODO Auto-generated method stub
return null;
}
}
It should be marked how an error by the compiler because String
is not annotated with @EntityDomain
What is the correct configuration?