Interface Wrapper<T>

Type Parameters:
T - the type of instances that be wrapped
All Known Subinterfaces:
WrapperAdapter<T>

public interface Wrapper<T>
This Wrapper interface is used to be implemented by wrapper classes, make an inspectable wrapper chain(linked list).

Note about wrapper chain:

  • The wrapper chain consists of wrapper itself, followed by the wrappers obtained by repeatedly calling unwrap_()
    Wrapper Chain
  • The last instance of wrapper chain is NEVER an instance of Wrapper
  • Uses the static methods of Inspector to inspect the wrapper chain
Author:
Jerry Lee (oldratlee at gmail dot com), Zava Xu (zava dot kid at gmail dot com)
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the underlying instance that be wrapped.
  • Method Details

    • unwrap_

      @NonNull T unwrap_()
      Returns the underlying instance that be wrapped.

      This method also make the wrapper instances as a wrapper chain(linked list), The wrapper chain consists of wrapper itself, followed by the wrappers obtained by repeatedly calling this method.

      Specification contracts:

      • Do NOT return null which makes no sense.
        If returns null, the inspection operations of Inspector will throw NullPointerException when touch the null unwrap value.
      • The wrapper chain can NOT be CYCLIC(aka. the return value/wrapper instance is duplicate on the wrapper chain).
        If cyclic, the inspection operations of Inspector will throw IllegalStateException when touch the duplicate unwrap instance.