Interface ClientProxy<T>
- Type Parameters:
T
- the proxied type
- All Known Implementing Classes:
AbstractClientProxy
public interface ClientProxy<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 TypeMethodDescriptiondefault T
$cast()
Returns thisClientProxy
, or a completely substitutable replacement for it, cast to the type of the instance it proxies.$proxied()
Returns the instance being proxied, not thisClientProxy
.
-
Method Details
-
$proxied
Returns the instance being proxied, not thisClientProxy
.- 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 thisClientProxy
, 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
ClientProxy
; 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
ClientProxy
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.
-