@Documented @Retention(value=RUNTIME) @Target(value=ANNOTATION_TYPE) public @interface InjectTag
Used to specify a certain annotation is an Inject tag.
Once an annotation is annotated with InjectTag it means the field or method is subjected to dependency injection without the need for Inject annotation.
For example, let’s say a developer want to create an annotation to inject fibonacci series:
@Retention(RetentionPolicy.RUNTIME)
@InjectTag
@LoadCollection(FibonacciSeriesLoader.class)
public @interface FibonacciSeries {
int max() default 100;
}
Because the FibonacciSeries is tagged with InjectTag, thus user can directly use it to mark a field is subject to dependency injection:
public class EvenFibonacciSeriesHolder {
@FibonacciSeries List<Integer> series;
}
If the FibonacciSeries annotation is not tagged with InjectTag, then it must add @Inject in order to mark the field needs dependency injection:
public class EvenFibonacciSeriesHolder {
@Inject @FibonacciSeries List<Integer> series;
}
Genie.registerInjectTag(Class[])Copyright © 2016–2018 OSGL (Open Source General Library). All rights reserved.