Interface DecoratingComponent

All Known Implementing Classes:
TracingEventStorageEngine, TracingSnapshotStore

public interface DecoratingComponent
Implemented by a ComponentDecorator output class to expose the single delegate it wraps, so code holding a decorated value can see through it back to whatever it was built from.

decoratedDelegate() must return the immediate delegate -- never this, and never something that requires further unwrapping this class isn't aware of -- so that unwrapFully(Object) always terminates.

Since:
5.4.0
Author:
John Hendrikx
  • Method Details

    • decoratedDelegate

      Object decoratedDelegate()
      Returns the single delegate this decorator wraps.
      Returns:
      the wrapped delegate; never null
    • unwrapFully

      default Object unwrapFully()
      Follows the decoratedDelegate() chain from this delegate down to its root, returning the first value encountered that is not itself a DecoratingComponent.
      Returns:
      the root delegate at the bottom of this instance's decoration chain; never null, provided every decoratedDelegate() in the chain honors its contract
    • unwrapFully

      static @Nullable Object unwrapFully(@Nullable Object value)
      Follows the decoratedDelegate() chain from the given value down to its root, returning the first value encountered that is not itself a DecoratingComponent.

      Returns value itself, unchanged, when it is not a DecoratingComponent to begin with.

      Parameters:
      value - the value to unwrap; may be null, in which case null is returned
      Returns:
      the root delegate at the bottom of value's decoration chain, or value itself if it is not decorated; null if value is null