Interface Proxy<T>

Type Parameters:
T - the proxied type

public interface Proxy<T>
An interface whose implementations pretend to be another type and alter the behavior of instances of that type in some way.

An implementation of this interface must, somehow, be able to be cast to the type of the instance it logically proxies.

Author:
Laird Nelson
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default T
    Returns this Proxy, or a completely substitutable replacement for it, cast to the type of the instance it proxies.
    Returns the instance being proxied, not this Proxy.
  • Method Details

    • $proxied

      Returns the instance being proxied, not this Proxy.
      Returns:
      the instance being proxied; never null; never this
      Idempotency:
      Implementations of this method must be idempotent and deterministic. Specifically, they must always return the instance being proxied, not this or anything else.
      Nullability:
      Implementations of this method must never return null.
      Thread Safety:
      Implementations of this method must be safe for concurrent use by multiple threads.
    • $cast

      default T $cast()
      Returns this Proxy, or a completely substitutable replacement for it, cast to the type of the instance it proxies.

      The default implementation of this method returns, effectively, (T)this.

      Returns:
      this Proxy; never null
      Throws:
      ClassCastException - if the cast could not take place for any reason; this indicates a violation of this interface's structural contracts by the implementation class
      Idempotency:
      Implementations of this method must be idempotent and deterministic. Specifically, they must always return this Proxy or a completely substitutable replacement for it, not anything else.
      Nullability:
      Implementations of this method must never return null.
      Thread Safety:
      Implementations of this method must be safe for concurrent use by multiple threads.