Package dev.getelements.elements.rt.util
Interface ProxyDelegate<DelegateT>
- Type Parameters:
DelegateT
-
public interface ProxyDelegate<DelegateT>
Provides a delegate type for any interface allowing the underlying implementation to be swapped out as necessary.
The swapping of the delegate is thread safe, but the delegated type may not be.
-
Method Summary
Modifier and TypeMethodDescriptiongetProxy()
Gets the underlying delegated type.static <ProxyDelegateT>
ProxyDelegate<ProxyDelegateT> Starts the delegate with the delegate suppler.stop()
Stops the delegated type, returning the delegate
-
Method Details
-
getProxy
DelegateT getProxy()Gets the underlying delegated type.- Returns:
- the delegate, or null
-
stop
DelegateT stop()Stops the delegated type, returning the delegate- Returns:
-
start
Starts the delegate with the delegate suppler. This will not invoke the supplier unless the instance is in the state to accept the delegate.- Parameters:
delegateTSupplier
- the suppleir- Returns:
- the delegated type
- Throws:
IllegalStateException
- if there is already a delegate
-
getProxy
static <ProxyDelegateT> ProxyDelegate<ProxyDelegateT> getProxy(Class<ProxyDelegateT> proxyDelegateTClass)
-