Interface ClassTemplateInvocationContext


@API(status=EXPERIMENTAL, since="6.0") public interface ClassTemplateInvocationContext
ClassTemplateInvocationContext represents the context of a single invocation of a @ClassTemplate.

Each context is provided by a ClassTemplateInvocationContextProvider.

Since:
5.13
See Also:
  • Method Details

    • getDisplayName

      default String getDisplayName(int invocationIndex)
      Get the display name for this invocation.

      The supplied invocationIndex is incremented by the framework with each class template invocation. Thus, in the case of multiple active providers, only the first active provider receives indices starting with 1.

      The default implementation returns the supplied invocationIndex wrapped in brackets — for example, [1], [42], etc.

      Parameters:
      invocationIndex - the index of this invocation (1-based).
      Returns:
      the display name for this invocation; never null or blank
    • getAdditionalExtensions

      default List<Extension> getAdditionalExtensions()
      Get additional extensions for this invocation.

      The extensions provided by this method will only be used for this invocation of the class template. Thus, it does not make sense to return an extension that needs to perform some action at the container level, such as an implementation of BeforeAllCallback.

      The default implementation returns an empty list.

      Returns:
      additional extensions for this invocation; never null or containing null elements, but potentially empty
    • prepareInvocation

      default void prepareInvocation(ExtensionContext context)
      Prepare the imminent invocation of the class template.

      This may be used, for example, to store entries in the Store to benefit from its cleanup support or for retrieval by other extensions.

      Parameters:
      context - the invocation-level extension context