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
-
Method Details
-
$proxied
Returns the instance being proxied, not thisProxy
.- Returns:
- the instance being proxied; never
null
; neverthis
- 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
Returns thisProxy
, 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
; nevernull
- 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.
-