I'd like to create a @Stub
, @Example
or @Mock
annotations in Java to indicate that some classes are just for testing. Also I like to make those classes as deprecated to discourage users of my library from using them. I like to make something similar to @Nullable
and other annotation in JSR305.
I came up with this:
import javax.annotation.meta.TypeQualifierNickname;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
@Deprecated
@Retention(RetentionPolicy.RUNTIME)
@TypeQualifierNickname
@Target(value=TYPE)
public @interface Stub {
}
And the use case:
@Stub
public final class SuperAwesome implements Feature {
}
Unfortunately, dispite of using @TypeQualifierNickname
, it seams like my @Stub
annotation being marked as deprecated by Intellij and javac compiler instead of target annotated class.
Is there a way, this may work without a need for changes in javac or IDE?