Annotation Interface Provides


@Documented @Target(TYPE) @Retention(RUNTIME) @API(status=STABLE, since="1.0") public @interface Provides
Defines which type the annotated class is bound to. It will be used when type lookups are made to find the class implementing or extending the required abstract instance. It works like ProvidedBy in the opposite direction.

All given provided classes must be super interfaces/classes of the annotated class. If that is not the case, injecting a class from the annotated class based on the binding will result in a class cast exception.

Note that providing instances for primitive and array types is not supported by this annotation. Due to the limitations of annotations, support for generics (like Collection<String>) is not possible.

Since:
1.0
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    @NotNull Class<?>[]
    Defines which class this instance should be bound to.
  • Element Details

    • value

      @NotNull @NotNull Class<?>[] value
      Defines which class this instance should be bound to. The given type must be super interface or class of the annotated class in order for this annotation to work correctly.
      Returns:
      the type to which the annotated class should get bound.