Recalll beta
  • Add Sub Topic
  • My Vault
    • Search
    • Change Password
    • Logout
Loading...
  • Programming
  • Java Annotations
  • Restricting an annotation's application by using @
Import from Url
  • Cat1
  • Cat2
  • Cat3
  • Cat4
  • Cat5
  • Cat2
  • Cat3
  • Cat4
  • Cat5
Rectangle 27 2

Restricting an annotation's application by using @Target

The type of element that an annotation can be applied to can be restricted using the @Target meta-annotation.

The @Target declaration takes the form of @Target(ElementType.<ELEMENT_TYPE>), where <ELEMENT_TYPE> is an element type from a predefined list. The available elements are:

  1. ANNOTATION_TYPE
  2. CONSTRUCTOR
  3. FIELD
  4. LOCAL_VARIABLE
  5. METHOD
  6. PARAMETER
  7. TYPE (any type of element)

For example:

@Target(ElementType.CONSTRUCTOR)

The annotation that is annotated with this will only be able to be applied to constructors.

Note Java annotations restrictions
Hidden

Discussion

View all 0 Comments
contact | privacy policy | terms of use © 2015-16 recalll Mobile Analytics

Modal header

Body...

Save