Interface Scope

All Superinterfaces:
AutoCloseable

public interface Scope extends AutoCloseable
A Scope that can be (eventually) closed. Used when making a span active.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    boolean
    Whether the method close() was already called or not.
    default <T> T
    unwrap(Class<T> scopeClass)
    Access the underlying scope by specific type.
  • Method Details

    • close

      void close()
      Specified by:
      close in interface AutoCloseable
    • isClosed

      boolean isClosed()
      Whether the method close() was already called or not.
      Returns:
      if this scope is closed
    • unwrap

      default <T> T unwrap(Class<T> scopeClass)
      Access the underlying scope by specific type. This is a dangerous operation that will succeed only if the scope is of expected type. This practically removes abstraction capabilities of this API.
      Type Parameters:
      T - type of the scope
      Parameters:
      scopeClass - type to access
      Returns:
      instance of the scope
      Throws:
      IllegalArgumentException - in case the scope cannot provide the expected type