Annotation Interface AnnotateWith


@Target({TYPE,ANNOTATION_TYPE}) @Retention(RUNTIME) public @interface AnnotateWith
Indicates that a generated code that implements the annotated interface is annotated with some annotations.

This annotation is mainly intended to inject a Config instance to a DAO implementation's constructor.

There are 2 ways to use this annotation:

  • annotate directly
  • annotate indirectly

annotate directly:

 @Dao
 @AnnotateWith(annotations = {
   @Annotation(target = AnnotationTarget.CONSTRUCTOR, type = javax.inject.Inject.class),
   @Annotation(target = AnnotationTarget.CONSTRUCTOR_PARAMETER, type = javax.inject.Named.class, elements = "\"config\"") })
 public interface EmployeeDao {
    ...
 }
 
annotate indirectly:
 @AnnotateWith(annotations = {
         @Annotation(target = AnnotationTarget.CONSTRUCTOR, type = javax.inject.Inject.class),
         @Annotation(target = AnnotationTarget.CONSTRUCTOR_PARAMETER, type = javax.inject.Named.class, elements = "\"config\"") })
 public @interface InjectConfig {
 }
 
 @Dao
 @InjectConfig
 public interface EmployeeDao {
    ...
 }
 
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description