Package sting

Annotation Interface StingProvider


Annotation that indicates the class that provides the service. This is an integration meta-annotation rather than a component-defining Sting annotation.

The class that provides the service may be either a Fragment-annotated type or an Injectable-annotated type. This annotation is applied to another framework's annotation to simplify integration with Sting. Sting consults it when the framework annotation is applied to a type element that Sting attempts to include or discover.

When used for explicit include aliasing, Sting resolves the framework-managed type in an Injector.includes() annotation parameter or a Fragment.includes() annotation parameter to the provider type. In this case, the resolved provider only needs to exist and be annotated with Fragment or Injectable. The provider does not need to publish the framework-managed type unless that type must later be resolved as a Sting service.

When used for auto-discovery, Sting resolves an unresolved service request for the framework-managed type to the provider type. In this case, the resolved provider must be annotated with Fragment or Injectable and publish the framework-managed type using the default qualifier.

Frameworks that synthesize Sting providers should remember that Sting only observes Eager, Named, and Typed on the resolved provider. Providers used only as explicit include aliases usually do not need to copy those annotations for the framework-managed type. Providers intended to support auto-discovery usually should copy them when they need Sting to treat the framework-managed type as published with those semantics. In practice this means copying the annotations onto the generated Injectable subtype, or onto the provider method declared by the generated Fragment, depending on the provider style.

The presence of this annotation does not itself create a Sting binding; the resolved provider type is what Sting processes.

It should be noted that Sting will attempt to use any annotation with this name and shape so that frameworks do not need a direct code dependency on Sting.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The name pattern of the class that provides the service.
  • Element Details

    • value

      @Nonnull String value
      The name pattern of the class that provides the service. The name is relative to the reference type (See above for how to determine the reference type). The package is the same package as the reference type. The pattern can include constant string parts as well as the following replacements:
      • [SimpleName]: The simple name of the class. i.e. For a top-level class like come.example.MyElement the simple name is "MyElement". For a nested class like come.example.MyElement.ElementType.Kind the simple name is "Kind".
      • [CompoundName]: The compound name of the class. i.e. For a top-level class like come.example.MyElement the compound name is "MyElement". For a nested class like come.example.MyElement.ElementType.Kind the simple name is "MyElement.ElementType.Kind".
      • [EnclosingName]: The compound name of the class with the simple name elided. i.e. For a top-level class like come.example.MyElement the enclosing name is "". For a nested class like come.example.MyElement.ElementType.Kind the enclosing name is "MyElement.ElementType.".
      • [FlatEnclosingName]: The enclosing name of the class with the dots replaced with underscores. i.e. For a top-level class like come.example.MyElement the flat enclosing name is "". For a nested class like come.example.MyElement.ElementType.Kind the flat enclosing name is "MyElement_ElementType_".

      A typical pattern used by a framework such as Arez is "[FlatEnclosingName]Arez_[SimpleName]"..

      Returns:
      the pattern to produce a name.