1

With java I can write something like that

public <T extends Enum> getValue (Class<T> clazz) {} 

Is there a way to parametrize not from Enum, but from Annotation? So example I want write something like this:

public <T extends @interface> getValue (Class<T> clazz) {} 

My goal is to be insure during compilation time that clazz variable is annotation. Any ideas? (except call class.isAnnotation inside a method)

1 Answer 1

1

Yes, all annotation types are subclasses of java.lang.annotation.Annotation.

The common interface extended by all annotation types.

Use

public <T extends Annotation> void /* or whatever */ getValue (Class<T> clazz) {} 
Sign up to request clarification or add additional context in comments.

1 Comment

Works. I have mistake in type parameters. :-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.