Search code examples
javaintellij-ideaannotationsintellij-14

Custom Annotations - defining @Target


A bit new to defining custom annotations, what am I doing wrong:

from: Target : Standard Annotations « Language « Java Tutorial

You can have multiple values in the Target annotation.

@Target(value={TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE})

However, I can't get this to work in my IDE

I must do something like this:

@Target(value={ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE})

What am I doing wrong?

I'm using IntelliJ 14


Solution

  • Just add:

    import static java.lang.annotation.ElementType.*;